In previous post we seen about reusing command line history.
Now I will explain about how to reuse previous command arguments.
With following command I am listing directory a b c d e
$ ls a b c d e
!$ is to use last argument of previous command.
Example:
$ ls !$
Above command will list directory e.
!:1 is to use first argument of previous command.
Example:
$ ls !:1
Above command will list directory a.
!:2 is to use second argument of previous command.
Example:
$ ls !:2
Above command will list directory b.
Similarly we can get other arguments.
We can generalize this as !:n where n is argument position and n start from 1 to and so on…
-Sany
Pingback: from Sany’s Linux Blog « meditationatae