Linux tar output sent to log file

I have a bit of a problem (or what seems like a problem to me). WHen running the tar from the linux console I get the following out put:

user@PC:~$ tar -cvf test.tar --totals ./files/examples/
Total bytes written: 399360 (390KiB, 3.1MiB/s)

This works great & works just as expected and is exactly the output I would like to see. However - when ever I run the same command and redirect the out put to a file for logging, I get:

user@PC:~$ tar -cvf test.tar --totals ./files/examples/ > test.log
Total bytes written: 399360 (390KiB, 16MiB/s)

The last bit of information Totals, is sent to STDOUT (console) rather than the log file. Would anyone know how I can get this information sent to my log?
Who is Participating?
pjedmondConnect With a Mentor Commented:
You probably need to read this:


tar -cvf test.tar --totals ./files/examples/ &> test.log

will direct stdout and stderr to the log file.


If you want to understand it all inside out, then you'll find this a 'fun' link:

NTNBowerAuthor Commented:
Perfect, thanks for the information it worked great, and I will check out the links you sent so I can get a better understainding of it.

It still strikes me as odd that the results of the internal option --totals sends its information to different output. From the above I would guess it is sending it to stderr - but doesnt that kind of seems like a bug?

Hands down you got the points, just curious if you might know why they did it this way.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.