且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何从管道中两次使用STDIN

更新时间:2023-12-04 12:30:16

您不需要使用管道.如果您使用的是bash,请使用将进程替换为<(cmd) ,即实现重定向,使过程的输入或输出(某些命令序列)显示为临时文件.

You don't need to use a pipe. If you are using bash use process-substitution as <(cmd) i.e. to achieve a redirection where the input or output of a process (some sequence of commands) appear as a temporary file.

awk 'FNR==NR {col1[$1]++; col2[$2]++; next} {print $0, col2[$2] "/" length(col1)}' <(cut -f3 5- input) <(cut -f3 5- input)