0
点赞
收藏
分享

微信扫一扫

量化交易之linux篇 - 重定向到另一个文件、shell脚本中读取另一个文件并输出到终端、将特定行重定向到指定文件、tee


永久重定向到另一个文件
#!/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里面

举报

相关推荐

0 条评论