Printing command from history without executing

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


# !100:p

!100 – 100th command in the history

:p – print the command instead of executing it


# !!:p

!! – last command entered

:p – print the command instead of executing it


About 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..............

Check Also

MySql replication

Disaster recovery of Mysql using DRBD and Heartbeat

Disaster recovery (DR) is the process, policies and procedures that are related to preparing for …