In this page I’ve collated commands that I’ve stumbled upon that I’ve found helpful.
Contents
- Grep
- Find
- zoxide
- Bash Expansion
Grep
grep can be used with -B# and -A# to display “#” number of lines before and after the result, we can also use -C# to return the same number of lines before and after. E.g. instead of grep -B4 -A4, just use grep -C4 instead.
also: ripgrep is faster than traditional grep
Find
fd like find but faster
fd -e (find with a specific extension)
fd -x (run a command on the file found e.g. rm)
Zoxide
Sometimes I’m working on a bunch of tasks and then I’ll forget which directory I was in half an hour ago. Zoxide can be used like this:
z bit-of-the-directory and it will cd into the directory e.g.
zi is an interactive mode that will show a text based UI with previously accessed directories! Timesaver.
bash expansion
To move a file but just change the extension use mv filename.{oldext,newext}
cp file{,_bak} will copy the file and append _bak to its original filename
compgen
compgen -c | grep ‘^command’ will list out all commands starting with (“^”) ‘command’.
