- find all files with extension recursively and delete them
bash
find . -name "*.png" -type f -delete
- make a directory multiple levels deep
bash
mkdir -p currentdir/newdir/foo
- recursively search bash history
bash
CTRL + r (tap r to cycle through history)
- go back to last working directory
bash
cd -
- repeat previous command with sudo
bash
sudo !!
- read latest entries on log files
bash
tail -f logfile
- get size of directory contents
bash
du -sh *
- kill process
bash
ps -e | grep {package} // get the pid from this
kill {pid} // pid from previous command
- find and replace using sed
bash
sed -i 's/oldstring/newstring/g' hello.txt
- search recursively for string and return line numbers of any occurrences
bash
grep -rn string .
- add following to .zshrc or .bash_profile to return files whose name contains a string
bash
f () { find . -name '*'"$@"'*' ; }