Tip 2:
type history.
All of your recent commands would be listed.
12 ls
13 sudo make && make install
14 cd ~/myapps/
Here, if you want to install the 13nth command (i.e., sudo make && make install)
Use as follow
!13
This will run the 13th command.
Tip 3:
Use ctrl + R to reverse search the history and type any part of the command.
For example, in the above case, if you press ctrl+R and then type sudo, the command "sudo make && make install" will be displayed.
If you want to run that command, press Enter.
Otherwise, presss ctrl+R till you get the relevent command.
If you dont't want to run anything, press ctrl+C.
Here is text.
To use previous argument (only one argument present)
$_ or !$
For example, vi ~/home/application/readme
Now, if you want to cat the file,
you can use
cat !$
Where there are many arguments, you can handle like following.
ls file1.txt file2.txt
and you wanted the first one, you could type
!:1
giving
file1.txt
If you want to use both arguments
!:1-2
This will list both files file1.txt and file2.txt
You can use any argument by mentioning the number of the argument as fillow
!:20-34
!:1-3
To run new command with all the arguments
!:^-$
No comments:
Post a Comment