Linux input-output-redirect Stdin/stdout/stderr

Source: Internet
Author: User
Tags stdin

redirect

Shell Edit Text

Graphical tools to edit files

1. redirect

Standard input

Standard output

Error output

[Email protected] kkk]#CatAaa.SH#!/bin/Basha=1 while[$a-le5 ] DoUseradd user$a let a++ Done[email protected] kkk]#./aaa.SH[email protected] kkk]#Tail/etc/passwdtcpdump:x: the: the::/:/sbin/nologinsky:x: -: -: sky:/home/sky:/bin/bashserver:x:501:501::/home/server:/bin/bashclient:x:502:502::/home/client:/bin/bashdhcpd:x:177:177:D HCP server:/:/sbin/nologinuser1:x:503:503::/home/user1:/bin/bashuser2:x:504:504::/home/user2:/bin/bashuser3:x:505:505::/home/user3:/bin/bashuser4:x:506:506::/home/user4:/bin/bashuser5:x:507:507::/home/user5:/bin/Bash[[email protected] kkk]#CatAaa1.SH#!/bin/Basha=1 while[$a-le5 ] Do   Echo "111"|passwd--stdin user$a//Standard input let a++ Done[email protected] kkk]#./aaa1.SHchange the password for the user user1. passwd: All the authentication tokens have been successfully updated. Change the password for the user user2. passwd: All the authentication tokens have been successfully updated. Change the password for the user User3. passwd: All the authentication tokens have been successfully updated. Change the password for the user user4. passwd: All the authentication tokens have been successfully updated. Change the password for the user user5. passwd: All the authentication tokens have been successfully updated.

[Email protected] kkk]#Cat 1. Txt//Standard Output11111111[email protected] kkk]#Cat  One. txt//standard Error OutputCat: One. txt: No file or directory [[email protected] kkk]#[[email protected] kkk]#Cat 1. Txt One. txt11111111Cat: One. txt: No file or directory [[email protected] kkk]#Cat 1. Txt One. txt >3. txt//standard output recorded at 3.TX, error output not recordedCat: One. txt: No file or directory [[email protected] kkk]#[[email protected] kkk]#Cat 3. txt11111111[email protected] kkk]#Cat 1. Txt One. txt1>4. Txt2>5. Txt[[email protected] kkk]#Cat 4. Txt//standard output 1 recorded in 4. TXT11111111[email protected] kkk]#Cat 5. Txt//error Output 2 recorded in 5. TXTCat: One. txt: No file or directory [[email protected] kkk]#

[Email protected] kkk]#CatTest.SH#!/bin/BashPing-C3 192.168.10.128 1>/dev/NULLif[$?-eq0 ]   Then  Echo "The host is up!"fi[email protected] kkk]#./test.SHThe host is up!//standard output of ping ignored[Email protected] kkk]#VITest.SH[email protected] kkk]#CatTest.SH#!/bin/BashPing-C3 192.168.10.128if[$?-eq0 ]   Then  Echo "The host is up!"fi[email protected] kkk]#./test.SHPING192.168.10.128(192.168.10.128) About( -) bytes of data. -Bytes from192.168.10.128: icmp_seq=1Ttl= -  Time=0.964Ms -Bytes from192.168.10.128: icmp_seq=2Ttl= -  Time=0.448Ms -Bytes from192.168.10.128: icmp_seq=3Ttl= -  Time=0.467Ms---192.168.10.128 PingStatistics---3Packets Transmitted,3Received0% packet loss, Time2003msrtt min/avg/max/mdev =0.448/0.626/0.964/0.239MS The host is up!//all standard outputs are recorded[Email protected] kkk]#

Linux input-output-redirect Stdin/stdout/stderr

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.