The role of |, grep, quotation marks in linux

I am playing arm+linux recently, it is inevitable to touch the bash script and record a few points.

| Piping

Use the pipe character "|" provided by Linux to separate the two commands, and the output of the command on the left side of the pipe character will be the input of the command on the right side of the pipe character. Continuous use of pipes means that the output of the first command will be used as the input of the second command, the output of the second command will be used as the input of the third command, and so on. Let's take a look at how the pipeline is used in constructing a Linux command.

grep

grep (global search regular expression(RE) and print out the line, search for regular expressions and print out the line) is a powerful text search tool that can search for text using regular expressions and print out the matching lines come out. The grep family of Unix includes grep, egrep, and fgrep. The commands of egrep and fgrep are only slightly different from grep. egrep is an extension of grep and supports more re metacharacters. fgrep is fixed grep or fast grep. They treat all letters as words, that is, metacharacters in regular expressions represent their own literal meaning , No longer special. Linux uses the GNU version of grep. It is more powerful, you can use the functions of egrep and fgrep through the -G, -E, -F command line options.
Knowledge of regular expressions is required here. For specific usage, you can view the help information with man grep or info grep.

quotation marks

Single quotation marks and double quotation marks are to solve the problem of spaces in between.
Because space is used as a typical separator in Linux. To avoid this problem, single quotes and double quotes were created. The difference between them is that single quotation marks will deprive all characters of the special meaning, while the'$' (parameter substitution) and'`' (command substitution) in double quotation marks are exceptions. Therefore, there is basically no difference between the two, unless the parameter substitution character $ and the command substitution character `are encountered in the content.

Guess you like

Origin blog.csdn.net/qq_44801767/article/details/107503817