cat <<-EOF >&2

cat <<-EOF >&2

cat >&2 <==> cat 1>&2 标准输出被重定向到错误输出 默认屏幕

<替换 <<累加

标准输入:代码为0 < <<

标准输出:代码为1 > >> 默认屏幕

标准错误输出:代码为2 2> 2>> 默认屏幕

find /home -name .bashrc > list_right 2> list_error #省略了1 1> list_right

find /home -name .bashrc > list  2> list #错误 两条数据写入同一个文件,交叉写入,次序错乱

find /home -name .bashrc > list 2>&1 #正确

区别:

1)cat food 2>&1 >file :错误输出到终端,标准输出被重定向到文件file。
2)cat food >file 2>&1 :标准输出被重定向到文件file,然后错误输出也重定向到和标准输出一样,所以也错误输出到文件file。

猜你喜欢

转载自www.cnblogs.com/idyllcheung/p/10310704.html