I have a awk script something like
awk 'FNR==NR {col1[$1]++; col2[$2]++; next} {print $0, col2[$2] "/" length(col1)}' input input
But in case I have lot of files and need to use this script for concatenated files together like:
cat *all_input | awk 'FNR==NR {col1[$1]++; col2[$2]++; next} {print $0, col2[$2] "/" length(col1)}' STDIN STDIN
Does not work. How to use STDIN twice from pipe?
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)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With