Bash: internal time command successful redirect

So today I was struggling with `time’ trying to get it to redirect. Basically what I wanted to do was time the output of a file, then pipe both timing and file output to gzip for compression.

After struggling with various suggestions I finally found one that worked:

{ { time date; } 2>&1; } | gzip - > output.gz

or less efficiently:

(( time date; ) 2>&1 ) | gzip -> output.gz

Leave a Reply

Your email address will not be published. Required fields are marked *