linux 命令输出结果 管道的方式 输入到后面命令的指定参数位置

比如我想将时间转换为unix时间戳

## 格式是这样
grep -a 'mineOn,it is not the winner at this round' /tmp/tmp.log|awk '{print $1}'
## 结果为
2021-07-01T23:59:49.015Z


现在想grep的命令输出的一行一行的数据作为参数传递到下一个命令指定参数位置 利用xargs 来完成

grep -a 'mineOn,it is not the winner at this round' /tmp/tmp.log|awk '{print $1}'|xargs -I{} date -d {} "+%s"

最终的效果

  1625183989

注: 这里只针对linux环境,macos下可能date的实现不一样没有-d参数 用其他方法替代

你可能感兴趣的:(linux 命令输出结果 管道的方式 输入到后面命令的指定参数位置)