Help Wanted - Article Ideas. Answers to these questions should be sent directly to the e-mail address of the inquirer with or without a copy to [email protected]. Answers that are copied to LG will be printed in the next issue in the Tips column. Before asking a question, please check the Linux Gazette FAQ to see if it has been answered there.
I will assume from your words that you're quite unfamiliar with Unix-style editors.
For this example I'll use VI (or any clone)... this will give you keystroke-by-keystroke instructions but have a care, there is no safety net -- if you flub it, you're on your own -- this is where learning these editors comes in pretty handy. At the command prompt, type 'vi -b script.pl' (don't type the quotation marks and replace script.pl with your perl script's name (and path, if it isn't in the current directory). That will load the script into the editor in binary (vs. plain text) mode. That will allow you to see the extraneous ^M (carriage return) characters that are giving you trouble. We can eliminate all of them in the script in one swell foop with a global search and replace command in a Unix-style editor. VI is a modal editor. By default it comes up in command mode (vs. editing mode) which is where we want to be. When you see <CTRL-SomeCharacter) below, it means hold down the Control key and press the SomeCharacter key (i.e. <CTRL-V> means hold Control and press V). Enter the following command (no quotes) :g/<CTRL-V><CTRL-M>/s///g then press Enter. Pressing the colon key starts a command entry. CTRL-V tells the editor that the next key is not to be taken literally, but to be accepted as a parameter. CTRL-M is a carriage return character. Type ':wq' (no quotes) to write the file and quit the editor. All done, but what did we do? Parsing the command... as stated above, the colon puts the editor into command entry mode. The first 'g' tells the editor we want to do a global operation. The text between the first and second slashes is the text to search for... we told the editor to search for a binary carriage return character by entering CTRL-V CTRL-M. The 's' tells the editor we want to do a search and replace operation on that text. The empty text between the next two sets of slashes tells the editor that we want to replace that text with nothing. The trailing 'g' tells the editor to go ahead and replace every instance of the specified text globally (in the whole file). As others have noted and I hope this post makes clear, Unix style editors are your friends and will save you much time and effort. There are dozens of ways to accomplish what we did here (stripping carriage returns from a file that has been edited with a Windows-style editor)... sed on the command line will do it simply as well, for instance. It is a common operation, one you should get familiar with as soon as possible, imo.
Hi Alice,Greetings from Microsoft Azure!These steps will work on your Ubuntu Machines I just happen to be installing it on a VM that is already running in Azure.After logging into the Ubuntu VM first you should go ahead an do a quick update to the VM. To update the machine running the followingcommand:sudo apt-get updateNext you will install the nodejs-legacy tools by running:sudo apt-get install nodejs-legacyNext install the Node Package Manager Tools with this commandsudo apt-get install npmFinal step is to use the Node Package Manager or npm to install the Azure CLI Tools.sudo npm install -g azure-cliAfter a successful installation run the Azure CLI Tool using the Azure commandazureNote:On some Linux distributions,you may receive an error similar to /usr/bin/env: ‘node’: No such file or directory.
This error comes from recent installations of nodejs being installed at /usr/bin/nodejs. To fix it, create a symbolic link to /usr/bin/node by running this command:sudo ln -s /usr/bin/nodejs /usr/bin/nodeRegards,Pradeep.
Comments are closed.
|
AuthorWrite something about yourself. No need to be fancy, just an overview. Archives
March 2023
Categories |