DEV Community

Cover image for Bash history
Mohamed Yahia
Mohamed Yahia

Posted on

Bash history

You can scroll the history of the commands you run by the up and down arrows in the terminal.

But in case you would like to look at the list of the comamnds you run you can type run history. It will print the commands in the terminal.

You can view them using less program by piping history to less history | less.

Once you find the command you woould like to re-run just exit if you are in less type ! followed by the line number of the command.

What you have done now is called history expansion. It is called like that because !1345 is expanded into the full command at the line number in the history file corresponding to the number you wrote.

The list file is located in the home directory under the name .bash_history

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Discover a treasure trove of wisdom within this insightful piece, highly respected in the nurturing DEV Community enviroment. Developers, whether novice or expert, are encouraged to participate and add to our shared knowledge basin.

A simple "thank you" can illuminate someone's day. Express your appreciation in the comments section!

On DEV, sharing ideas smoothens our journey and strengthens our community ties. Learn something useful? Offering a quick thanks to the author is deeply appreciated.

Okay