5 Bash Tips for Beginners
Useful command line tricks every developer should know.
The power of the command line
Bash is the Swiss army knife of every developer. Here are 5 tips that will improve your workflow.
1. History search with Ctrl+R
Instead of typing long commands again, press Ctrl+R and type part of the command. Bash searches your history.
(reverse-i-search)`docker': docker compose up -d
2. Switching directories quickly
With cd - you jump back to the previous directory:
$ cd /var/log
$ cd /etc
$ cd -
/var/log
3. Brace expansion
Create several files or folders at once:
$ mkdir -p projekt/{src,tests,docs}
$ touch datei_{1..5}.txt
4. The !! operator
Run the last command again - perfect for a forgotten sudo:
$ apt update
Permission denied
$ sudo !!
sudo apt update
5. Process substitution
Compare the output of commands directly:
$ diff <(ls dir1) <(ls dir2)
Happy Hacking!