永久重定向到另一个文件
#!/bin/bash
exec 1>>test // >> 为追加写入, > 为覆盖写入, 1为文件代号, 如果有需要写入的另一个文件用:exec 2 >> test2
echo my name is tqz
echo hello linux
echo this is all...
shell脚本中读取另一个文件并输出到终端
#!/bin/bash
exec 0<test
count=1
while read line
do
echo "line #$count: $line"
count=$[ $count +1 ]
done
将特定行重定向到指定文件
#!/bin/bash
exec 3>test
echo my name is tqz
echo hello linux >&3
echo thank you...
date | tee test // 将 date信息记录到test里面