Linux Base--i/o Redirection

Source: Internet
Author: User

Output REDIRECT symbol:

: Overwrite output

>>: Append output

SET-C: Prohibit overwrite redirection of existing files

Force overwrite output after prohibit setting, use >|

Set +c: Turn off the above features

Standard output

Override mode standard output redirection [[email protected] basic]# ls /var > a.txt[[email protected]  BASIC]# CAT A.TXT ACCOUNTCACHECRASHCVSDB Append mode standard output REDIRECT [[email protected] basic]#  ll /home >> a.txt[[email protected] basic]# cat a.txt  accountcachecrashcvsdbemptytotal 16948-rw-r--r--   1 root      root      5484681 dec  8 12:24 4.1.0. tar.gzdrwxr-xr-x   2 root     root          4096 DEC 20 10:55 BASICDRWX------   2 chenchao  chenchao     4096 Dec 14 17:34 chenchaodrwxrwxr-x    8 root     root          4096 dec  8 12:25 ipython-4.1.0drwxr-xr-x.  2 root     root          4096 DEC  7 19:05 LOGSDRWX------.   2  root     root        16384 dec   7 19:00 lost+found

Standard error Output

Override mode standard error output redirect [[email protected] basic]# ll/var12 2> b.txt[[email protected] basic]# cat b.txt ls:cannot access/var12  : No such file or directory Append mode standard error output redirect [[email protected] basic]# ll/var12 2>> b.txt[[email protected] basic]# cat B.txt ls:cannot access/var12:no Such file or directoryls:cannot access/var12:no such file or directory

Standard output and standard error output simultaneous redirection

[Email protected] basic]# ll/var12 &> b.txt [[email protected] basic]# ll/var &> b.txt [email protecte  D] basic]# cat b.txt Total 76drwxr-xr-x. 2 root root 4096 Dec 03:43 accountdrwxr-xr-x.  Root root 4096 Dec 7 19:04 cachedrwxr-xr-x.  2 root root 4096 Nov 23:19 crashdrwxr-xr-x.  2 root root 4096 Nov cvsdrwxr-xr-x. 3 root root 4096 Dec 7 19:04 DB

i.e. output to screen and save to file

[[email protected] basic]# echo "Hello word" | Tee C.txthello word[[email protected] basic]# cat c.txt Hello Word


This article from "Liang Childe" blog, please be sure to keep this source http://iyull.blog.51cto.com/4664834/1884189

Linux Base--i/o Redirection

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.