Scripting: managing output in a multi-step operation
by raindogtoo from LinuxQuestions.org on (#5220V)
I've set up the majority of my scripts to send output (STDOUT & STDERR) to a specific log file using the following format:
script command >> $LOGFILE 2>&1
However that approach isn't working with the following command set:
partclone.ext4 -c -q -s input_device | gzip -c --fast >output_file >> $LOGFILE 2>&1
In this case, the partclone/gzip output ends up being stored in $LOGFILE which obviously is not where it needs to go.
Is there a way to pipe the output to gzip and then into the appropriate destination but still send the console status and error messages to $LOGFILE?


script command >> $LOGFILE 2>&1
However that approach isn't working with the following command set:
partclone.ext4 -c -q -s input_device | gzip -c --fast >output_file >> $LOGFILE 2>&1
In this case, the partclone/gzip output ends up being stored in $LOGFILE which obviously is not where it needs to go.
Is there a way to pipe the output to gzip and then into the appropriate destination but still send the console status and error messages to $LOGFILE?