在Shell中,标准错误写法为 2>, 标准输出为 1> 或者 >。如要要将标准输出和标准错误合二为一,都重定向到同一个文件,可以使用下面两种方式:
方式一: > out.txt 2>&1
[[email protected] ~]# { time ls /etc; } > out.txt 2>&1
方式二: &> out.txt
[[email protected] ~]# { time ls /etc; } &> out.txt
在Shell中,标准错误写法为 2>, 标准输出为 1> 或者 >。如要要将标准输出和标准错误合二为一,都重定向到同一个文件,可以使用下面两种方式:
方式一: > out.txt 2>&1
[[email protected] ~]# { time ls /etc; } > out.txt 2>&1
方式二: &> out.txt
[[email protected] ~]# { time ls /etc; } &> out.txt