Linux should learn this--command set 7 (Pipeline command)

Source: Internet
Author: User

1. Pipe command symbol "|" function is to use the standard output of the previous command as the standard input for the latter command, in the form: " command a| command B".

The command to find the restricted login user is: grep "/sbin/nologin"/etc/passwd

The command to count the number of lines of text is: Wc-l

The output value of the search order is passed to the statistic command, in fact, as long as the pipe Fu Jian in the middle can be:

grep "/sbin/nologin"/etc/passwd|wc-l

Appendix:

The pipe character command is entirely possible: command a| Command b| command C

2. View the home directory information:

ls/home/

To view information about the ZZZZZ directory:

LS zzzzz/

These two as if the command has been executed successfully, but in fact there is a difference, the former is returned by the standard output , the latter execution fails to return the error output .

Standard input (STDIN, file descriptor 0): The default is input from the keyboard, and 0 indicates the output from other files or commands.

Standard output (STDOUT, file descriptor 1): The default output to the screen, 1 indicates the file.

Error output (STDERR, file descriptor 2): The default output to the screen, 2 indicates the file.

There are these conditions for output redirects:

There are these conditions for the input redirection character:

Empty the original content data:

echo "Jacun" > Test.txt

Append to the original content:

echo "Jacun" >> test.txt

REDIRECT the Test.txt file as input to the wc-l command to calculate the number of rows:

Cat Test.txt | Wc-l

Equivalent to:

Wc-l < Test.txt

Linux should learn this--command set 7 (Pipeline command)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.