Category Archives: Basic Linux Tutorial

Difference between grep, tr, cut, sed and awk commands

  1. grep can only shows the lines matching pattern. You can not transform the output.
  2. tr command is used to replace the characters with other set of characters. Remember that sed works at pattern level.
  3. cut command is used to extract characters, fields from a file. We can also specify the delimiter that separate the columns. Even though we can achieve same thing using sed command, it is recommended to use cut command for simplicity.
  4. sed command is super set of grep, tr and cut command. Additionally it can transform output. sed is mainly used for extraction and substitution.
  5. awk is a super set of sed. awk supports programming. awk is mainly used when the data is in the table format. It also allows to delete matching lines
    We can use programming constructs like for loop and conditions