Sunday, May 17, 2009
2:03 AM

More on Inserting Arguments from Previous Commands

I previously blogged on using the shortcut Alt + dot to insert the last argument from the previous command.

Suppose you don't want the last argument. Instead, you want to insert the first, second, or third argument of a previous command.

No problem!

Alt + 1 + dot inserts the first argument of the last command. To key it in properly, hold the alt key, press the 1 key, and then the dot (".") key.

Similarly, alt + 2 + dot inserts the second command argument.

For example, you just executed this command.
$ ls -l /home/peter/somefile.txt   secondfile.txt
-rw-r--r-- 1 peter peter 8115 2007-12-19 21:03 somefile.txt
$

If you now type in cat and then alt + 2 + dot, it will insert the second argument from the last command (-l is the first).
$ cat /home/peter/somefile.txt 


You can repeat the key sequence, and this will go back 1 command at a time, and insert the specified argument of that command.

If you want just the command itself, not an argument, type in alt + 0 + dot .


P.S. Related articles from this blog:

StumbleUpon Toolbar

0 comments:

Post a Comment