Shell Cheatsheet


Explain shell

Scroll through (vim) output by page

Instead of holding down up and down to scroll through a long page:

  • space to move down by page
  • b to move back up by page

Quickly move from end to start of a command prompt

Instead of holding down the left and right arrow keys to move through a command prompt

  • CTRL + a to go to the start of the prompt
  • CTRL + e to go to the end of a prompt

Search through a directory of files for a regex string content

grep -Hn -r -E 'user.+account' ./dir_path

Copy all the file contents of a directory

find /home/vagrant/dotfiles -type f -print0 | xargs -0 cp -t $HOME
  • Use find with flags -type f -print0 to list out all the files in the target directory with a null char delimiter instead of a new line
  • this allows for the selection of file names with whitespaces and such
  • pipe the results into xgargs with flag -0 telling it that the arguments are separated by null chars
  • xargs is like .map on the Unix command line, it turns what has been piped into it into a list of arguments to then call the following command on each one
· bash , shell , cheatsheet