Printing command from history without executing

March 22nd, 2010 | Your thoughts are welcome | Posted in Misc

We all know that, BASH stores the commands we entered in the terminal to .bash_history, we can see those commands using history command. Commands in the history can be executed by ! followed by the number,  !5 (5th command in the history will get executed). But what if we only need to print the command, instead of executing, we can do it by :p

Ex:1

# !100:p

!100 – 100th command in the history

:p – print the command instead of executing it

Ex:2

# !!:p

!! – last command entered

:p – print the command instead of executing it

|

Leave a Reply 431 views, 2 so far today |

Author : Anoop Nair

I am a Linux and Networking geek, Interest to learn more and fun to do new experiments, happy to share knowledge that I have learned and experienced in my life and carrier, also trying to learn more on Firewalls, Linux, Switching, Routing etc..............

Leave a Reply

CommentLuv Enabled