This content originally appeared on DEV Community and was authored by Yassine Sallami
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
Need only your last few commands? Try using tail:
$ history | tail -n 3
4 history
5 history | grep conda
6 history | tail -n 3
đź’ˇ 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.
This content originally appeared on DEV Community and was authored by Yassine Sallami
Yassine Sallami | Sciencx (2024-10-26T21:41:00+00:00) 🛠️ Command Line Tips for Boosting Efficiency. Retrieved from https://www.scien.cx/2024/10/26/%f0%9f%9b%a0%ef%b8%8f-command-line-tips-for-boosting-efficiency/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.