How to pipe output of command to two separate commands and store outputs
3
votes
1
answer
1287
views
I have a really long command that runs over a huge file and I am forced to run it twice which doubles the time it takes to run.
This is what I am doing at the moment:
x=$(command | sort -u)
y=$(command | sort -n)
I was wondering whether there is any way to redirect the output of command to both -u
and -n
and store output of each into separate variables or files like I did above with
and
.
I tried to use tee to do the following but no luck:
command | tee >(sort -n > x.txt) >(sort -u > y.txt)
I tried to redirect output to text files but it just printed it to standard output instead.
Any tips or ideas?
Asked by markovv.sim
(35 rep)
Oct 27, 2020, 07:44 PM
Last activity: Feb 25, 2025, 06:09 PM
Last activity: Feb 25, 2025, 06:09 PM