Dec 30, 2012

Unix Shortcuts 1


a) !!    #to run the previous command 

e.g.,
>>pwd
>>!!  #executes "pwd" command

b) Control+P #move up through history list, one command at a time. (Up arrow key) 


c) Control+N #move down (or Down arrow key). 

d) !n #run nth command in history list. where n is a number from your history list. 


e.g.,
>>history

1 ls

2 pwd
3 vim test.txt
4 vim ~/aliases
5 vim ~/.vimrc
6 history

>>!3 #runs 3rd command in the history i.e., vim test.txt

>>!-2 #runs 2nd command from the end of history i.e., vim ~/.vimrc

e) !n:p   #only preview command number n (will not execute the command). 

f) !string   #Run most recent command starting with characters in string.


e.g.,

>>vim text.txt

>>pwd
>>ls -lrt
>>mkdir test
>>!vim     press<Enter> #Runs most recent command starting with "vim"
>>!ls press<Enter> #Runs most recent command starting with "ls"

g) Move the cursor to beginning of line in Unix Terminal
Beginning of line     Ctrl+a

h) Move the cursor to end of line in Unix Terminal
End of line           Ctrl+e


No comments:

Post a Comment