So I have this command I need to run then disown:

innobackupex-1.5.1 --user=root --password=**** --stream=tar ./ | gzip - > /data/myfile.tar.gz

How do I pipe any output to a file?

adding another >> to the end of this command only appends the gzip data.

to be more specific; innobackupex has progress output - I want this output appended/piped to a file (not just errors). The normal way of doing this (by adding >>) will not work in this case due to the gzip already piping

  • Really ambiguous question Tom. Just look at your answers. – goldilocks Jan 29 '13 at 20:04

innobackupex doesn't output its progress on stdout, otherwise, it would end up in the tar.gz file. Most likely, it outputs it to stderr (a quick glance at the script seems to confirm it), so what you need to do is redirect its stderr:

innobackupex ... 2>> progress.log | gzip > file.tar.gz

Do you mean to capture STDERR from innobackupex? Your question isn't very clear.

innobackupex-1.5.1 --user=root --password=**** --stream=tar ./ 2> /path/to/file | gzip - > ... 
  • STDOUT from innobackupex piped to a file would be since there is a lot of information - especially progress information - – Tom G11 Jan 29 '13 at 20:09
  • Ummm ... that doesn't explain what you want to achieve, either. You're already handling STDOUT from innobackupex using the pipe into gzip. – tink Jan 29 '13 at 20:13

I would do it by means of running these commands in a subshell

( innobackupex-1.5.1 --user=root --password=**** --stream=tar ./ \
   | gzip - >  /data/myfile.tar.gz ) 2> errors

1) If you mean, you want to pipe the output to both gzip for compression and a regular file, here's an example of tee usage:

ls -a ~ | tee ls.txt - | grep "^\."

This will print all of the "hidden" dot files in your home directory (because of grep), but the entire output of ls -a will be in ls.txt.

See man tee for a complete explanation.

2) If you mean you want to include the standard error stream in the standard output stream, append 2>&1 to the command.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.