🚀 author: “Big Data Zen”

🚀 Column introduction: This column mainly shares Linux technology, will involve the common Linux command operation, common service applications and related operation and maintenance knowledge, as well as some Linux system in-depth analysis.

🚀 Fan benefit: Join the big data community of Xiaochan

🚀 Welcome to like 👍, collect ⭐, leave a message 💬

1: What is input redirection?

In layman’s terms, input redirection is the writing of input information to a specified file

2: What is output redirection?

In layman’s terms, output redirection means writing the output information to a file, rather than sending the output information to the console.

3: What is error redirection?

In layman’s terms, error redirection means writing the wrong information to a file

In Linux everything is a file
File descriptor: POSIX name File descriptor Function /dev/stdin0The standard input is /dev/stdout1The standard output is /dev/stderr2Standard error outputCopy the code
1: input redirection: <
Eg: wc -l <123.txt  # input 123.txt, the number of trips will be counted
Copy the code
2: output redirection: > indicates write overwrite (previous 123.txt content will be overwritten); >> # stands for appending (continues to write)
Eg: the cat > >123.txt ;
 cat > 123.txt ; ls -lrt >123.TXT (can also write lS-LRT listed content output to123.TXT); echo'123455' > 123.TXT (12345The input to the123.TXT)# ls-LTR (bottom to top);
ls -lrt /home/ # list everything in the home directory
Copy the code
3. Error redirection :(write 2 after error redirection, and omit the 1 to standard output)

For example, if you type LLLL, because this is an incorrect command, the system will print -bash: LLLL: command not found. TXT file. -bash: LLLL: command not found. Linux error output to bottomless pit:

Eg: LLLL2> 123.TXT. llll2> /dev/null                      
#/dev/null null null null
Copy the code
Several symbols common symbols

Ls-lrt /boot /test 1>/root/123.txt 2>&1 #1 is standard input

Ls -lrt /boot /test &>123.txt This symbol is all typed into this folder.

| # pipe # cat/ect/passwd | grep root # listed the contents of this pipe is the passwd, grep after the passwd contains the column list of the characters. (See last line for grep recall)

; # represent can perform multiple command cat/etc/passwd | grep root; Ls -lrt # Run cat /etc/passwd and then grep root

&&(and) LLLL && echo 123# if the command before it is executed successfully, the command after it is executed successfully. If the previous command fails to be executed, the subsequent command cannot be executed.

| | (two pipeline operator is the or) # symbol in front of the command is successful at the back of the command not implemented

Grepgrep ‘119.4.253.206’ 123. TXT | wc – # l find 123. TXT in the list containing the string of Numbers, need accurate matching is combined with – parameter, followed by the | wc -l can be counted the number of rows.