Some of my favorite bash commands - 2025
| find ./ -name “ | This is a useful command for searching through our file system. |
|---|---|
| sed -i ‘s/old-text/new-text/g’ filename.txt | Replace a string every time its found in a file name |
| Touch filename.txt | Create the file filename.txt |
| ls *.txt | xargs cat | list (ls) all files that end with *.txt and pipe them in to the cat command with xargs to print out their content |
| git diff –name-only | xargs -r code {} | Nice command to pipe the file names in a git diff into code to automatically open files with differences for editing |
| tree | Nice installable command to list out file structures |
| > > | Redirects the standard output to a file, but appends to the end of the file instead of overwriting it. |
| > | Redirects the standard output (stdout) of a command to a file, overwriting the file’s contents (or creating it if it doesn’t exist). |
| | | Sends the standard output of the command on the left as the standard input (stdin) to the command on the right. This chains commands together. |
| Those last three were for me to remember | |
| grep “pattern1” filename | grep -v “pattern2” | Search for pattern1 in files then exclude lines with pattern2 from the output. |
I also recommend the following article for some more advanced git commands: 10 Advanced Git Commands
Enjoy Reading This Article?
Here are some more articles you might like to read next: