Skip to content

Instantly share code, notes, and snippets.

@jpotts18
Last active February 7, 2020 21:09
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 jpotts18/741b1e01ed1bf5a939b6fa13457dee1c to your computer and use it in GitHub Desktop.
Save jpotts18/741b1e01ed1bf5a939b6fa13457dee1c to your computer and use it in GitHub Desktop.
linux cheat sheet

tail

-n = number of lines to show
-f = follow
-q = quite (don't show file headers)
  • Foreground logs so you can see logs but still access shell tail -f /var/log/something.log &
  • Combine multiple log files tail -q -f /var/log/auth.log -f /var/log/messages

grep

-H = Print the file name of each match
-n = line number
-r = recursive
-i = ignore case
  • Look for usage of a string in a directory grep -Hnir '<string>' .
  • Look before and after string grep -Hnir -A 5 -B 5 'otter' .

Cool Stuff

  • How many functions in a python codebase grep -Hir 'def ' . | cut -d':' -f1 | uniq -c | sort -nr
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment