bash


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