###1 重定向
[root@localhost tmp]# ls -l 1-parameter.sh
-rw-rw-r--. 1 zhxu zhxu 50 Nov 7 11:51 1-parameter.sh
[root@localhost tmp]# ls -l 1-parameter.sh > 1.txt #标准输出
[root@localhost tmp]# ls -l 1-parametreeeeeeeeee.sh > 1.txt
ls: cannot access 1-parametre.sh: No such file or directory
[root@localhost tmp]# ls -l 1-parametre.sh 2> 1.txt #错误输出
[root@localhost tmp]# cat 1.txt
ls: cannot access 1-parametre.sh: No such file or directory
[zhxu@localhost tmp]$ ls -l ../tmp/ &> text #正确和错误输出
[zhxu@localhost tmp]$ ls -l ../tmpppp/ &>> text #正确和错误输出
[zhxu@localhost tmp]$ cat text
total 0
-rw-rw-r--. 1 zhxu zhxu 0 Nov 19 19:42 text
ls: cannot access ../tmpppp/: No such file or directory
[zhxu@localhost tmp]$
###2
[root@localhost tmp]# wc -l < /etc/passwd #读取文件内容的行数
39
[root@localhost tmp]#
[root@localhost tmp]# wc -l /etc/passwd #读取文件,并读取行数
39 /etc/passwd
[root@localhost tmp]#
###3
重定向:命令 文件
管道符:命令 命令
[root@localhost tmp]# echo "root" | passwd --stdin root #任意门
Changing password for user root.
passwd: all authentication tokens updated successfully.
[root@localhost tmp]#