New Linux shortcut learnt

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 "

Advertisements

~ by WYSIWYG on May 11, 2006.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: