In a single command how do you run the previous command in
the command prompt.

Answer Posted / joker

!! will execute the last command
!-1 will execute the 2nd command from last

Few other tricks:
-----------------

If you are not sure you can see what is the command rather than executing by

!!:p
!-2:p

and later just do !!

If you want to run the last command with little modification use substitution

!!:s/old/new

example:

>vim test
>!!:s/test/abcd/:p
vim abcd

Thanks,
Joker

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

I want to connect to a remote server and execute some commands, how can I achieve this?

787


What is the first line in a shell script?

777


Explain about non-login shell files?

891


Devise a script that takes file name as arguement(which must present in the current directory)and locates from your home directory tree all thpath names of its links.Then mail the list to self.

1910


What does the sh command do?

815


What is bash eval?

749


What is the equivalent of a file shortcut that we have a window on a linux system?

820


What are the advantages of shell scripting?

816


shell script for reverse the string

1083


I want to monitor a continuously updating log file, what command can be used to most efficiently achieve this?

967


madhar chod unix ke 10 commands dhang se likh nahi sakta hai

3203


What is wc in shell script?

738


What is the difference between scripting and coding?

732


What happens when you type ls?

752


What is the syntax of "nested if statement" in shell scripting?

812