"Linux goods products in the input-output"

Input and output in Linux

Input
stdin [standard input stream ]
input system refers to the system information transmitted to the external
of a system external to the data transmission system is as follows
1. Keyboard
2. Mouse
3. Enter the command
output

Export as standout [Standard correctly entered] stderr [standard error]
In the string of commands executed successfully completed Command string generated by the failure to complete execution
Output signal is 1 linux stderr output signal in the linux 2

Character device
Character device refers to the character units of transmission devices in I / O transfer process, such as a keyboard, a printer,
a character memory device is a virtual device opened and real
"Linux goods products in the input-output"

Redirect the output find / etc / -name passwd

Note: You must under ordinary users

1> 2> &>
Correct output Error output All output

Applet:> westos Empty file

2 find / etc / -name passwd added: do not overwrite the original file
"Linux goods products in the input-output"

find / etc / -name passwd> westos.out correct output is stored in the westos.out
"Linux goods products in the input-output"

"Linux goods products in the input-output"

"Linux goods products in the input-output"
"Linux goods products in the input-output"

add to

Additional right / wrong / all

"Linux goods products in the input-output"
"Linux goods products in the input-output"
"Linux goods products in the input-output"
"Linux goods products in the input-output"
"Linux goods products in the input-output"
"Linux goods products in the input-output"

"Linux goods products in the input-output"

pipeline

Channel definitions: the output becomes the input of the last command

symbol use
2>&1 Converting the output of No. 1 of 2
lee Copy output to the specified position
'Pipe symbol

Example: 3 to 5 show the history of output lines
"Linux goods products in the input-output"

[student@workstation Desktop]$ ls /bin | wc -l  ##统计/bin有多少文件
1612
[student@workstation Desktop]$ find /etc/ -name passwd | wc -l  ##默认只有正确输出可以通过管道
find: ‘/etc/pki/rsyslog’: Permission denied
find: ‘/etc/dhcp’: Permission denied
find: ‘/etc/polkit-1/rules.d’: Permission denied
find: ‘/etc/polkit-1/localauthority’: Permission denied
find: ‘/etc/sssd’: Permission denied
find: ‘/etc/grub.d’: Permission denied
find: ‘/etc/audit’: Permission denied
find: ‘/etc/firewalld’: Permission denied
find: ‘/etc/sudoers.d’: Permission denied
find: ‘/etc/lvm/archive’: Permission denied
find: ‘/etc/lvm/backup’: Permission denied
find: ‘/etc/lvm/cache’: Permission denied
find: ‘/etc/libvirt’: Permission denied
find: ‘/etc/cups/ssl’: Permission denied
2
[student@workstation Desktop]$ find /etc/ -name passwd 2>&1 | wc -l    ##将错误输出定向到正确输出存放位置
16
[student@workstation Desktop]$ find /etc/ -name passwd | tee file | wc -l  #复制输出到file文件再通过管道统计
find: ‘/etc/pki/rsyslog’: Permission denied
find: ‘/etc/dhcp’: Permission denied
find: ‘/etc/polkit-1/rules.d’: Permission denied
find: ‘/etc/polkit-1/localauthority’: Permission denied
find: ‘/etc/sssd’: Permission denied
find: ‘/etc/grub.d’: Permission denied
find: ‘/etc/audit’: Permission denied
find: ‘/etc/firewalld’: Permission denied
find: ‘/etc/sudoers.d’: Permission denied
find: ‘/etc/lvm/archive’: Permission-

** input redirection

To modify the password, for example

"Linux goods products in the input-output"
"Linux goods products in the input-output"

Input redirection symbol


command << [输入标识]
内容
...
...
[输入标识]

More convenient, do not have to enter a password, direct editing in vim
1. vim editing westos.sh file. The passwd direct input, a password is required to change the password at
2. input redirection symbols, it is more convenient to directly edit
"Linux goods products in the input-output"
"Linux goods products in the input-output"

-

Guess you like

Origin blog.51cto.com/14653135/2463408