[youtube=http://youtu.be/nK4ZY6NBAGg] To re-run the previous command, we can use the below special way in bash.
!!#This re-runs the previous command
But the question is, why should i run ‘!!’ instead of using up arrow for previous command. One quick use case would be for running ‘sudo’. We often end up in ‘Permission denied’ error and re-run the same command […]
We often used to type a lengthy command and realize the error after running the command. To correct this error, either we used to re-type the whole command or edit (after up arrow). This can be easily handled with bash tricks by using ‘^’. Example:
Sometime we may want to run a range of commands which was run in the past (captured in ‘history’ command). This can be achieved using ‘fc’ command. Run ‘history’ command to find the range you want to re-run. For example, range from 1000 to 1010.
The above command will copy the range of commands […]