Linux file processing three musketeers (grep, sed, awk)

Everything in Linux is a file, and the file exists in the form of text, which is readable, writable, and executable (binary file). When we use linux, we need to be proficient in reading, editing, and filtering text.

In Linux, there are three powerful text processing tools, namely grep, sed, and awk, which provide us with great help in using the Linux system. 

1. Text filtering tool grep

1. grep usage

grep is global search regular expression and print out the line, comprehensively search for regular expressions and print them to the command line. It searches by line, outputs by line, and checks the target file step by step according to the pattern specified by the user. It can be used directly or mixed with other commands through the pipe character (|).

Basic usage:

grep [options] [pattern] 文件名

options:

Common options:

  • -v: reverse selection, display lines that are not matched by pattern;
  • -e: only display the matched string;
  • -i: Ignore character case;                   
  • -w: Match a fixed word to display the line;
  • -c: Count the number of matched lines;             

Guess you like

Origin blog.csdn.net/qq_35029061/article/details/130611596