Linux redirection and pipelines, Linux redirection Pipelines

Source: Internet
Author: User

Linux redirection and pipelines, Linux redirection Pipelines
Standard output redirection

">" OPERATOR: overwrite the content of the target file

huey@huey-K42JE:~/huey/linux/cmdline$ date > foohuey@huey-K42JE:~/huey/linux/cmdline$ cat fooFri May 8 09:55:42 CST 2015

">" OPERATOR: append the output content to the end of the target file

huey@huey-K42JE:~/huey/linux/cmdline$ date >> foohuey@huey-K42JE:~/huey/linux/cmdline$ cat fooFri May 8 09:55:42 CST 2015Fri May 8 09:57:02 CST 2015

 

Standard Error redirection

"2>" OPERATOR: overwrite the content of the target file

huey@huey-K42JE:~/huey/linux/cmdline$ ls inexistent_dir 2> ls-error.txt huey@huey-K42JE:~/huey/linux/cmdline$ cat ls-error.txt ls: cannot access inexistent_dir: No such file or directory

"2>" OPERATOR: append the output content to the end of the target file

huey@huey-K42JE:~/huey/linux/cmdline$ ls inexistent_dir 2>> ls-error.txt huey@huey-K42JE:~/huey/linux/cmdline$ cat ls-error.txt ls: cannot access inexistent_dir: No such file or directoryls: cannot access inexistent_dir: No such file or directory

 

Redirects standard output and standard errors to the same file

"&>" OPERATOR: overwrite the content of the target file

huey@huey-K42JE:~/huey/linux/cmdline$ date &> foohuey@huey-K42JE:~/huey/linux/cmdline$ cat fooFri May 8 10:16:12 CST 2015huey@huey-K42JE:~/huey/linux/cmdline$ ls inexistent_dir &> foo huey@huey-K42JE:~/huey/linux/cmdline$ cat fools: cannot access inexistent_dir: No such file or directory

"&>" OPERATOR: append the output content to the end of the target file

huey@huey-K42JE:~/huey/linux/cmdline$ echo 'hello world' > foohuey@huey-K42JE:~/huey/linux/cmdline$ date &>> foohuey@huey-K42JE:~/huey/linux/cmdline$ ls inexistent_dir &>> foo huey@huey-K42JE:~/huey/linux/cmdline$ cat foohello worldFri May 8 10:25:24 CST 2015ls: cannot access inexistent_dir: No such file or directory

 

Standard input redirection

"<" Operator

huey@huey-K42JE:~/huey/linux/cmdline$ echo 'hello world' > foohuey@huey-K42JE:~/huey/linux/cmdline$ cat < foohello world

 

MPs queue

"|" Operator

huey@huey-K42JE:~/huey/linux/cmdline$ ls /usr/bin | grep '^zip'zipzipcloakzipgrepzipinfozipnotezipsplit

 

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.