I have a very big zip file (~10 GB) which I want to unzip, and the result has to be passed to two commands. The results of both subsequent commands have to be appended to a file, and
Currently, I run
unzip -p bigFile.zip | head -n 1 >> output.txt
unzip -p bigFile.zip | grep -v 'skipLine' >> output.txt
which gives about a million rows. Now, I want to do it in 1 line. Using tee
, I came up with
unzip -p bigFile.zip | tee >(head -n 1 >> output.txt) >(grep -v 'skipLine'
>> output.txt)
But then the output.txt
file only contains 51 rows, of which the last line is not even complete. Also, the latter command prints the results to the terminal, which I do not want.
I have also tried
unzip -p bigFile.zip | tee >(head -n 1 >> output.txt) | grep -v 'skipLine'
>> output.txt
but unfortunately, this did not work either.
Any help is greatly appreciated! It is not necessary to use tee
, any other command works fine, as long as I can pass the output of the unzip
part to both the head
and grep
commands.
EDIT: It would be even better if the outputs of the head
and grep
commands could be 'combined' and then passed to zip
. Is this possible?