小编use*_*129的帖子

拆分不同命令的输入并组合结果

我知道如何组合不同命令的结果

paste -t',' <(commanda) <(commandb)
Run Code Online (Sandbox Code Playgroud)

我知道将相同的输入管道传输到不同的命令

cat myfile | tee >(commanda) >(commandb)
Run Code Online (Sandbox Code Playgroud)

现在如何组合这些命令?这样我才能做到

cat myfile | tee >(commanda) >(commandb) | paste -t',' resulta resultb
Run Code Online (Sandbox Code Playgroud)

说我有一个文件

我的文件:

1
2
3
4
Run Code Online (Sandbox Code Playgroud)

我想新建一个文件

1 4 2
2 3 4
3 2 6
4 1 8
Run Code Online (Sandbox Code Playgroud)

我用了

cat myfile | tee >(tac) >(awk '{print $1*2}') | paste
Run Code Online (Sandbox Code Playgroud)

会给我垂直的结果,我真的想以水平顺序粘贴它们。

bash pipe shell-script text-processing process-substitution

8
推荐指数
1
解决办法
1963
查看次数

如何按时间拖尾日志文件?

说我的日志文件(log.txt)是这样的

2014-01-01 22:30:30 something happened....
2014-01-01 22:30:31 something happened....
2014-01-01 22:30:41 something happened....
Run Code Online (Sandbox Code Playgroud)

我想拖尾这个文件以显示最后一小时的日志,并继续拖尾..

IE

tail <some magic to specify last 1 hour> -f log.txt
Run Code Online (Sandbox Code Playgroud)

然后输出是

2014-01-01 21:30:41 something happened....
...
2014-01-01 22:30:30 something happened....
2014-01-01 22:30:31 something happened....
2014-01-01 22:30:41 something happened....
Run Code Online (Sandbox Code Playgroud)

有没有工具可以做到这一点?

linux command-line bash shell-script tail

8
推荐指数
1
解决办法
6万
查看次数