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

How to get the last line from a file using just the terminal?

664


What are the different types of shell scripting?

532


What are the different variables present in linux shell?

608


What does $@ mean bash?

664


Given a file find the count of lines containing the word "abc".

950






What are the zombie processes?

563


Tell something about the super block in shell scripting?

569


What is the difference between break and continue commands?

566


What does it mean to debug a script?

567


How would you compare the strings in a shell script?

543


What is another name for a bash shell script that you might see?

1008


What is shell terminal?

547


How does ls command work?

582


How to check if the previous command was run successfully?

587


Explain about debugging?

605