New Linux shortcut learnt
Posted by puneeth on May 11, 2006
My Technical Architect showed me a shortcut today. I never knew such a thing existed, albeit I had always longed for it. Whenever you want to replace a character from the previous command with a new character, you would have pressed an "Up Arrow", then use the "Right Arrow/Left Arrow" and reach the character you want to replace, delete it and add the new character. Here's a shortcut that can be used effectively to avoid you the pain!!!
Example : Suppose you had created a file called "abc1002100.txt" in previous command.
$vi abc1002100.txt
Now suppose you want to create a file abc1003100.txt, why go to previous command till "2" is reached and replace it with"3". An easier and effective way is :
$ ^2^3
The above command will do the replacement for you and opens the file you requested for.
Note: It will replace all occurence of first character with the second character. For e.g, if you want to replace just the first "0" with "5", it is not possible with the shortcut mentioned. This shortcut will replace all occurence of first character with the second character. So the command that gets executed will be "vi abc1552155.txt "
Posted in Linux | No Comments »