๐Ÿ› ๏ธ Command Line Tips for Boosting Efficiency

yassinesallami

Yassine Sallami

Posted on October 26, 2024

๐Ÿ› ๏ธ Command Line Tips for Boosting Efficiency

Command Line Tips for Boosting Efficiency

Ever found yourself needing to search through your command history? Here are some quick tricks to make your terminal life easier:

๐Ÿ” Search History

You can instantly rerun your last command by typing !!. Want to search for a specific command you ran? Pair history with grep:

$ history | grep conda
3 conda activate dnakey
5 history | grep conda
Enter fullscreen mode Exit fullscreen mode

Need only your last few commands? Try using tail:

$ history | tail -n 3
4 history
5 history | grep conda
6 history | tail -n 3
Enter fullscreen mode Exit fullscreen mode

๐Ÿ’ก Quick Command Fix
Made a typo in your last command? Use ^oldtext^newtext^ to replace part of it without retyping everything. For example:

$ ^conda^pip^

This reruns the previous command, but with conda replaced by pip.

๐Ÿงน Cleaning Up History
Need to delete a specific command from your history? Just specify the line number:

$ history -d <line number>

Or clear your entire history file with history -c.

These shortcuts make navigating your command history faster and more efficient.

๐Ÿ’– ๐Ÿ’ช ๐Ÿ™… ๐Ÿšฉ
yassinesallami
Yassine Sallami

Posted on October 26, 2024

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related

ยฉ TheLazy.dev

About