Sep 2015 - review, ls and a little deeper on grep

From Jacksonville Linux Users Group
Jump to: navigation, search
  • ls #list files (blah blah blah, we know that) by default in alphabetical order.
  • man ls #displays the "manual" for the "ls" command
  • ls -a #displays all files (even the hidden ones)
  • ls -l #displays the files and their attributes/permissions
  • ls -al #does both -a and -l
  • ls -lh #shows file sizes in "human readable" format (e.g., 1K 234M 2G)
  • ls -t #sort by modification time, newest first
  • ls -r #reverse order while sorting
  • grep -A n pattern #also display n number of lines After the matching pattern
  • grep -B n pattern #also display n number of lines Before the matching pattern
  • grep -i n pattern #case Insensitive search
  • grep -v pattern #Inverse search, only print lines that do NOT match the pattern
  • grep '19\|20\|25' calendar #searches calendar for 19, 20 or 25!