Skip to content

Instantly share code, notes, and snippets.

@djm158
Last active April 2, 2018 19:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save djm158/6ca758d5702bc33750c28ac6cd5415bb to your computer and use it in GitHub Desktop.
Save djm158/6ca758d5702bc33750c28ac6cd5415bb to your computer and use it in GitHub Desktop.
useful bash utilities
# grep for multiple patterns and replace a pattern (or leave 'bar' empty to remove that pattern)
grep 'pattern1\|pattern2\|pattern3' file | sed 's/foo/bar/g'
# list directoy, grab date, time, and filename, sort by most recent
ls -l | awk '{print $6, $7, $8, $9}' | sort --reverse
# if you only want to ls by time
# add -ltr for reverse
ls -lt
# run process in background without exiting on terminal exit
nohup myprogram > myprogram.out &
# get the disk usage of a directory
du -sh path/to/folder
# get number of processors
grep -c ^processor /proc/cpuinfo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment