“nohup cat” — write the complete content to the log file rather to concatenate file

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















I used the below command



nohup cat fastp-filtered/OZBenth*_R1.fastp.fq.gz > fastp-filtered-merged4racon/merge_R1.fq.gz > merge_R1.out.log 2>&1 &


but unfortunately, the output went to merge_R1.out.log and not to merge_R1.fq.gz.



What did I miss?










share|improve this question
























  • What do you expect from cat fastp-filtered/OZBenth*_R1.fastp.fq.gz > fastp-filtered-merged4racon/merge_R1.fq.gz This will be mess from compressed files and with high probability will not be able to decompress

    – Romeo Ninov
    Mar 15 at 11:21











  • @RomeoNinov No it wouldn't. The concatenated file, when uncompressed, would be concatenation of the uncompressed files. This is likely what is intended and it will work.

    – Kusalananda
    Mar 15 at 12:43











  • cat <(tar zcf - a) <(tar zcf - b) | tar -ztf - shows a.

    – Weijun Zhou
    Mar 15 at 12:50











  • @WeijunZhou Yes, because two concatenated tar archives don't make much sense. Try cat <( gzip -cf <<<"HELLO" ) <( gzip -cf <<<"WORLD" ) | gzip -dc instead. The result would be the same as cat <( echo HELLO ) <( echo WORLD )

    – Kusalananda
    Mar 15 at 12:58











  • @WeijunZhou What the user is dealing with here is a collection compressed text files containing genomic "fastq" sequence data. They are merging the compressed files together and will later used the merged file for something. There will be no issues with this.

    – Kusalananda
    Mar 15 at 13:00


















0















I used the below command



nohup cat fastp-filtered/OZBenth*_R1.fastp.fq.gz > fastp-filtered-merged4racon/merge_R1.fq.gz > merge_R1.out.log 2>&1 &


but unfortunately, the output went to merge_R1.out.log and not to merge_R1.fq.gz.



What did I miss?










share|improve this question
























  • What do you expect from cat fastp-filtered/OZBenth*_R1.fastp.fq.gz > fastp-filtered-merged4racon/merge_R1.fq.gz This will be mess from compressed files and with high probability will not be able to decompress

    – Romeo Ninov
    Mar 15 at 11:21











  • @RomeoNinov No it wouldn't. The concatenated file, when uncompressed, would be concatenation of the uncompressed files. This is likely what is intended and it will work.

    – Kusalananda
    Mar 15 at 12:43











  • cat <(tar zcf - a) <(tar zcf - b) | tar -ztf - shows a.

    – Weijun Zhou
    Mar 15 at 12:50











  • @WeijunZhou Yes, because two concatenated tar archives don't make much sense. Try cat <( gzip -cf <<<"HELLO" ) <( gzip -cf <<<"WORLD" ) | gzip -dc instead. The result would be the same as cat <( echo HELLO ) <( echo WORLD )

    – Kusalananda
    Mar 15 at 12:58











  • @WeijunZhou What the user is dealing with here is a collection compressed text files containing genomic "fastq" sequence data. They are merging the compressed files together and will later used the merged file for something. There will be no issues with this.

    – Kusalananda
    Mar 15 at 13:00














0












0








0








I used the below command



nohup cat fastp-filtered/OZBenth*_R1.fastp.fq.gz > fastp-filtered-merged4racon/merge_R1.fq.gz > merge_R1.out.log 2>&1 &


but unfortunately, the output went to merge_R1.out.log and not to merge_R1.fq.gz.



What did I miss?










share|improve this question
















I used the below command



nohup cat fastp-filtered/OZBenth*_R1.fastp.fq.gz > fastp-filtered-merged4racon/merge_R1.fq.gz > merge_R1.out.log 2>&1 &


but unfortunately, the output went to merge_R1.out.log and not to merge_R1.fq.gz.



What did I miss?







bash io-redirection cat nohup






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 15 at 12:17









Kusalananda

141k18263439




141k18263439










asked Mar 15 at 10:39









user977828user977828

3491617




3491617












  • What do you expect from cat fastp-filtered/OZBenth*_R1.fastp.fq.gz > fastp-filtered-merged4racon/merge_R1.fq.gz This will be mess from compressed files and with high probability will not be able to decompress

    – Romeo Ninov
    Mar 15 at 11:21











  • @RomeoNinov No it wouldn't. The concatenated file, when uncompressed, would be concatenation of the uncompressed files. This is likely what is intended and it will work.

    – Kusalananda
    Mar 15 at 12:43











  • cat <(tar zcf - a) <(tar zcf - b) | tar -ztf - shows a.

    – Weijun Zhou
    Mar 15 at 12:50











  • @WeijunZhou Yes, because two concatenated tar archives don't make much sense. Try cat <( gzip -cf <<<"HELLO" ) <( gzip -cf <<<"WORLD" ) | gzip -dc instead. The result would be the same as cat <( echo HELLO ) <( echo WORLD )

    – Kusalananda
    Mar 15 at 12:58











  • @WeijunZhou What the user is dealing with here is a collection compressed text files containing genomic "fastq" sequence data. They are merging the compressed files together and will later used the merged file for something. There will be no issues with this.

    – Kusalananda
    Mar 15 at 13:00


















  • What do you expect from cat fastp-filtered/OZBenth*_R1.fastp.fq.gz > fastp-filtered-merged4racon/merge_R1.fq.gz This will be mess from compressed files and with high probability will not be able to decompress

    – Romeo Ninov
    Mar 15 at 11:21











  • @RomeoNinov No it wouldn't. The concatenated file, when uncompressed, would be concatenation of the uncompressed files. This is likely what is intended and it will work.

    – Kusalananda
    Mar 15 at 12:43











  • cat <(tar zcf - a) <(tar zcf - b) | tar -ztf - shows a.

    – Weijun Zhou
    Mar 15 at 12:50











  • @WeijunZhou Yes, because two concatenated tar archives don't make much sense. Try cat <( gzip -cf <<<"HELLO" ) <( gzip -cf <<<"WORLD" ) | gzip -dc instead. The result would be the same as cat <( echo HELLO ) <( echo WORLD )

    – Kusalananda
    Mar 15 at 12:58











  • @WeijunZhou What the user is dealing with here is a collection compressed text files containing genomic "fastq" sequence data. They are merging the compressed files together and will later used the merged file for something. There will be no issues with this.

    – Kusalananda
    Mar 15 at 13:00

















What do you expect from cat fastp-filtered/OZBenth*_R1.fastp.fq.gz > fastp-filtered-merged4racon/merge_R1.fq.gz This will be mess from compressed files and with high probability will not be able to decompress

– Romeo Ninov
Mar 15 at 11:21





What do you expect from cat fastp-filtered/OZBenth*_R1.fastp.fq.gz > fastp-filtered-merged4racon/merge_R1.fq.gz This will be mess from compressed files and with high probability will not be able to decompress

– Romeo Ninov
Mar 15 at 11:21













@RomeoNinov No it wouldn't. The concatenated file, when uncompressed, would be concatenation of the uncompressed files. This is likely what is intended and it will work.

– Kusalananda
Mar 15 at 12:43





@RomeoNinov No it wouldn't. The concatenated file, when uncompressed, would be concatenation of the uncompressed files. This is likely what is intended and it will work.

– Kusalananda
Mar 15 at 12:43













cat <(tar zcf - a) <(tar zcf - b) | tar -ztf - shows a.

– Weijun Zhou
Mar 15 at 12:50





cat <(tar zcf - a) <(tar zcf - b) | tar -ztf - shows a.

– Weijun Zhou
Mar 15 at 12:50













@WeijunZhou Yes, because two concatenated tar archives don't make much sense. Try cat <( gzip -cf <<<"HELLO" ) <( gzip -cf <<<"WORLD" ) | gzip -dc instead. The result would be the same as cat <( echo HELLO ) <( echo WORLD )

– Kusalananda
Mar 15 at 12:58





@WeijunZhou Yes, because two concatenated tar archives don't make much sense. Try cat <( gzip -cf <<<"HELLO" ) <( gzip -cf <<<"WORLD" ) | gzip -dc instead. The result would be the same as cat <( echo HELLO ) <( echo WORLD )

– Kusalananda
Mar 15 at 12:58













@WeijunZhou What the user is dealing with here is a collection compressed text files containing genomic "fastq" sequence data. They are merging the compressed files together and will later used the merged file for something. There will be no issues with this.

– Kusalananda
Mar 15 at 13:00






@WeijunZhou What the user is dealing with here is a collection compressed text files containing genomic "fastq" sequence data. They are merging the compressed files together and will later used the merged file for something. There will be no issues with this.

– Kusalananda
Mar 15 at 13:00











1 Answer
1






active

oldest

votes


















2














Redirections are processed in a left-to-right fashion.



When executing a command like



somecommand >f1 >f2 >f3


the shell will first create or truncate (empty) the file f1, then f2 and lastly f3. Then it starts somecommand with its standard output connected to f3.



To save the output of a command to multiple files, you would have to duplicate the data for each output file. This is easiest done with tee:



somecommand | tee f1 f2 >f3


This sends the output of somecommand to tee which duplicates it into the two files f1 and f2. The tee utility also produces the same data on its own standard output, and in the command above we simply redirect this into f3.



In your case, you would use



nohup cat fastp-filtered/OZBenth*_R1.fastp.fq.gz 2>&1 |
tee fastp-filtered-merged4racon/merge_R1.fq.gz >merge_R1.out.log &


The 2>&1 makes the error stream from cat be sent to tee as well (this may not be wanted as any errors would corrupt the resulting archive).



tee truncates its output files, just like > would do. Use tee with its -a option to append data to an output file.




It's unlikely that you actually meant for all output from cat to be written to two files though, so assuming that you want to save the errors to the log file and the concatenated archives to the output file, you would instead do



nohup cat fastp-filtered/OZBenth*_R1.fastp.fq.gz 
>fastp-filtered-merged4racon/merge_R1.fq.gz
2>merge_R1.out.log &


without the need for using tee at all.






share|improve this answer

























  • Conceptually correct, but I don't think this is what the OP is asking for.

    – Weijun Zhou
    Mar 15 at 12:37











  • @WeijunZhou I just realized this. It's unclear what they want to write into the log file.

    – Kusalananda
    Mar 15 at 12:38











Your Answer








StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f506474%2fnohup-cat-write-the-complete-content-to-the-log-file-rather-to-concatenate%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









2














Redirections are processed in a left-to-right fashion.



When executing a command like



somecommand >f1 >f2 >f3


the shell will first create or truncate (empty) the file f1, then f2 and lastly f3. Then it starts somecommand with its standard output connected to f3.



To save the output of a command to multiple files, you would have to duplicate the data for each output file. This is easiest done with tee:



somecommand | tee f1 f2 >f3


This sends the output of somecommand to tee which duplicates it into the two files f1 and f2. The tee utility also produces the same data on its own standard output, and in the command above we simply redirect this into f3.



In your case, you would use



nohup cat fastp-filtered/OZBenth*_R1.fastp.fq.gz 2>&1 |
tee fastp-filtered-merged4racon/merge_R1.fq.gz >merge_R1.out.log &


The 2>&1 makes the error stream from cat be sent to tee as well (this may not be wanted as any errors would corrupt the resulting archive).



tee truncates its output files, just like > would do. Use tee with its -a option to append data to an output file.




It's unlikely that you actually meant for all output from cat to be written to two files though, so assuming that you want to save the errors to the log file and the concatenated archives to the output file, you would instead do



nohup cat fastp-filtered/OZBenth*_R1.fastp.fq.gz 
>fastp-filtered-merged4racon/merge_R1.fq.gz
2>merge_R1.out.log &


without the need for using tee at all.






share|improve this answer

























  • Conceptually correct, but I don't think this is what the OP is asking for.

    – Weijun Zhou
    Mar 15 at 12:37











  • @WeijunZhou I just realized this. It's unclear what they want to write into the log file.

    – Kusalananda
    Mar 15 at 12:38















2














Redirections are processed in a left-to-right fashion.



When executing a command like



somecommand >f1 >f2 >f3


the shell will first create or truncate (empty) the file f1, then f2 and lastly f3. Then it starts somecommand with its standard output connected to f3.



To save the output of a command to multiple files, you would have to duplicate the data for each output file. This is easiest done with tee:



somecommand | tee f1 f2 >f3


This sends the output of somecommand to tee which duplicates it into the two files f1 and f2. The tee utility also produces the same data on its own standard output, and in the command above we simply redirect this into f3.



In your case, you would use



nohup cat fastp-filtered/OZBenth*_R1.fastp.fq.gz 2>&1 |
tee fastp-filtered-merged4racon/merge_R1.fq.gz >merge_R1.out.log &


The 2>&1 makes the error stream from cat be sent to tee as well (this may not be wanted as any errors would corrupt the resulting archive).



tee truncates its output files, just like > would do. Use tee with its -a option to append data to an output file.




It's unlikely that you actually meant for all output from cat to be written to two files though, so assuming that you want to save the errors to the log file and the concatenated archives to the output file, you would instead do



nohup cat fastp-filtered/OZBenth*_R1.fastp.fq.gz 
>fastp-filtered-merged4racon/merge_R1.fq.gz
2>merge_R1.out.log &


without the need for using tee at all.






share|improve this answer

























  • Conceptually correct, but I don't think this is what the OP is asking for.

    – Weijun Zhou
    Mar 15 at 12:37











  • @WeijunZhou I just realized this. It's unclear what they want to write into the log file.

    – Kusalananda
    Mar 15 at 12:38













2












2








2







Redirections are processed in a left-to-right fashion.



When executing a command like



somecommand >f1 >f2 >f3


the shell will first create or truncate (empty) the file f1, then f2 and lastly f3. Then it starts somecommand with its standard output connected to f3.



To save the output of a command to multiple files, you would have to duplicate the data for each output file. This is easiest done with tee:



somecommand | tee f1 f2 >f3


This sends the output of somecommand to tee which duplicates it into the two files f1 and f2. The tee utility also produces the same data on its own standard output, and in the command above we simply redirect this into f3.



In your case, you would use



nohup cat fastp-filtered/OZBenth*_R1.fastp.fq.gz 2>&1 |
tee fastp-filtered-merged4racon/merge_R1.fq.gz >merge_R1.out.log &


The 2>&1 makes the error stream from cat be sent to tee as well (this may not be wanted as any errors would corrupt the resulting archive).



tee truncates its output files, just like > would do. Use tee with its -a option to append data to an output file.




It's unlikely that you actually meant for all output from cat to be written to two files though, so assuming that you want to save the errors to the log file and the concatenated archives to the output file, you would instead do



nohup cat fastp-filtered/OZBenth*_R1.fastp.fq.gz 
>fastp-filtered-merged4racon/merge_R1.fq.gz
2>merge_R1.out.log &


without the need for using tee at all.






share|improve this answer















Redirections are processed in a left-to-right fashion.



When executing a command like



somecommand >f1 >f2 >f3


the shell will first create or truncate (empty) the file f1, then f2 and lastly f3. Then it starts somecommand with its standard output connected to f3.



To save the output of a command to multiple files, you would have to duplicate the data for each output file. This is easiest done with tee:



somecommand | tee f1 f2 >f3


This sends the output of somecommand to tee which duplicates it into the two files f1 and f2. The tee utility also produces the same data on its own standard output, and in the command above we simply redirect this into f3.



In your case, you would use



nohup cat fastp-filtered/OZBenth*_R1.fastp.fq.gz 2>&1 |
tee fastp-filtered-merged4racon/merge_R1.fq.gz >merge_R1.out.log &


The 2>&1 makes the error stream from cat be sent to tee as well (this may not be wanted as any errors would corrupt the resulting archive).



tee truncates its output files, just like > would do. Use tee with its -a option to append data to an output file.




It's unlikely that you actually meant for all output from cat to be written to two files though, so assuming that you want to save the errors to the log file and the concatenated archives to the output file, you would instead do



nohup cat fastp-filtered/OZBenth*_R1.fastp.fq.gz 
>fastp-filtered-merged4racon/merge_R1.fq.gz
2>merge_R1.out.log &


without the need for using tee at all.







share|improve this answer














share|improve this answer



share|improve this answer








edited Mar 15 at 12:40

























answered Mar 15 at 12:33









KusalanandaKusalananda

141k18263439




141k18263439












  • Conceptually correct, but I don't think this is what the OP is asking for.

    – Weijun Zhou
    Mar 15 at 12:37











  • @WeijunZhou I just realized this. It's unclear what they want to write into the log file.

    – Kusalananda
    Mar 15 at 12:38

















  • Conceptually correct, but I don't think this is what the OP is asking for.

    – Weijun Zhou
    Mar 15 at 12:37











  • @WeijunZhou I just realized this. It's unclear what they want to write into the log file.

    – Kusalananda
    Mar 15 at 12:38
















Conceptually correct, but I don't think this is what the OP is asking for.

– Weijun Zhou
Mar 15 at 12:37





Conceptually correct, but I don't think this is what the OP is asking for.

– Weijun Zhou
Mar 15 at 12:37













@WeijunZhou I just realized this. It's unclear what they want to write into the log file.

– Kusalananda
Mar 15 at 12:38





@WeijunZhou I just realized this. It's unclear what they want to write into the log file.

– Kusalananda
Mar 15 at 12:38

















draft saved

draft discarded
















































Thanks for contributing an answer to Unix & Linux Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f506474%2fnohup-cat-write-the-complete-content-to-the-log-file-rather-to-concatenate%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown






Popular posts from this blog

How to check contact read email or not when send email to Individual?

Displaying single band from multi-band raster using QGIS

How many registers does an x86_64 CPU actually have?