简单地用 < 或 > 时,相当于使用 0< 或 1>
ls > file1
ls -alh >>file2
read a< test_file.txt
echo $a # 只读入第一行
cmd > file 2>&1 把标准错误重定向到标准输出,再重定向到file,即stderr和stdout都被输出到file中
cmd &> file 功能与上一个相同,更为简便的写法。
cmd >& file 功能仍与上一个相同。
cmd > f1 2>f2 把stdout重定向到f1,而把stderr重定向到f2
mkdir newdir 2> /dev/null
find /etc -iname "*.service" 2> /dev/null
find . -type f 1> file1 2>&1
ls >& /dev/null