[root@ansible ~]# # 标准输出与错误输出重定向至同一位置[root@ansible ~]# ll /usr /not-exist &> log[root@ansible ~]# head -5 log
ls: cannot access '/not-exist': No such file or directory
/usr:
total 116
dr-xr-xr-x. 2 root root 24576 Oct 19 09:38 bin
drwxr-xr-x. 2 root root 6 May 11 2019 games
[root@ansible ~]# [root@ansible ~]# # 标准输出与错误输出重定向至不同位置[root@ansible ~]# ll /usr /not-exist > stdout 2> stderr[root@ansible ~]# head -3 stdout
/usr:
total 116
dr-xr-xr-x. 2 root root 24576 Oct 19 09:38 bin
[root@ansible ~]# cat stderr
ls: cannot access '/not-exist': No such file or directory
[root@ansible ~]#
多命令执行
符号
说明
;
多命令一块执行
&&
前面的命令正确执行,后面的命令才会执行
||
前面的命令不正确执行,后面的命令才会执行
[root@ansible ~]# date; ls /usr
Mon Oct 19 16:21:45 CST 2020
bin games include lib lib64 libexec local sbin share src tmp
[root@ansible ~]# dates; ls /usr
-bash: dates: command not found
bin games include lib lib64 libexec local sbin share src tmp
[root@ansible ~]# [root@ansible ~]# date && ls /usr
Mon Oct 19 16:23:50 CST 2020
bin games include lib lib64 libexec local sbin share src tmp
[root@ansible ~]# dates && ls /usr
-bash: dates: command not found
[root@ansible ~]# [root@ansible ~]# date || ls /usr
Mon Oct 19 16:22:44 CST 2020
[root@ansible ~]# dates || ls /usr
-bash: dates: command not found
bin games include lib lib64 libexec local sbin share src tmp
[root@ansible ~]#