tar not reading if output directed to /dev/null

Thread Tools Search this Thread
Operating Systems Linux Ubuntu tar not reading if output directed to /dev/null
# 1  
Old 09-08-2009
tar not reading if output directed to /dev/null

I stumbled across a somewhat strange behavior of tar and find no explanation for it: i was testing a DVD for read errors and thought to simply tar the content and direct the output to /dev/null:

tar -cvf - /my/mountpoint/*ts > /dev/null

This way i expected the system to read the complete content and eventually to report a read error if there is one. To my amazement the command came back immediately without any error. Still i didn't believe it had read anything (save for maybe the directory information) so i directed the output to a real file instead.
tar -cvf - /my/mountpoint/*ts > /tmp/somefile

This time tar did read the files and subsequently reported the read error i was expecting in one file.

My question is, why didn't it read the files before? Is there something i am missing?

# 2  
Old 09-08-2009
I too did experimentation, but it displayed all the file names.

Before that why you would want to tar and check the integrity, better you can do by reading all the files !!

Use find command with exec, or use dd command with bs & count to read.
# 3  
Old 09-08-2009
The parameter after "-f" is the archive filename. A value of "-" when there is no pipeline has no sensible meaning.


tar -cvf /dev/null /my/mountpoint/*ts
# 4  
Old 09-08-2009
First off, I'd like to state that i do NOT have a problem. I just want to achieve a better understanding. So you don't need to tell me workarounds, as i have already found one.

Originally Posted by thegeek
Before that why you would want to tar and check the integrity, better you can do by reading all the files !!
This is exactly what i was expecting tar to do: read all the files.

Originally Posted by methyl
The parameter after "-f" is the archive filename. A value of "-" when there is no pipeline has no sensible meaning
Sorry, but this is simply not true: the dash as a filename is signifying <stdout> and if i use a redirection or a pipeline to manipulate tars output further should make no difference.

In fact (as i have stated in my first post) the command worked the way i wrote it when i used a real file (instead of /dev/null) as output destination. It is this inconsistency - the command reading all the files when a real file is the destination and not working, when the destination is /dev/null - i want to understand.

# 5  
Old 09-09-2009
Does your OS have the equivalent of truss on Solaris. When a program is run with truss system calls are output to STDERR. If you have something like that running tar with that and then redirecting the output to /dev/null and a regular file might show you why it ends so soon.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting


Friends have the following problem a search may not find anything which would correct example: ls -ltr *prueba.txt | nawk '{ print $9 }' > Procesar.dat 2>/dev/null When he finds nothing gives me the following error ls: prueba.txt: No such file or directory because 2> / dev / null... (4 Replies)
Discussion started by: tricampeon81
4 Replies

2. Shell Programming and Scripting

redirect the audio output to /dev/null

I'm using an text-to-speech synthesis in a script, and I need to redirect it's output to /dev/null how can I do that ? And how to redirect the stream to his normal output then (sound card ) ? thankx (2 Replies)
Discussion started by: firelink
2 Replies

3. Shell Programming and Scripting

Redirecting standard out to /dev/null goes to file "/dev/null" instead

I apologize if this question has been answered else where or is too elementary. I ran across a KSH script (long unimportant story) that does this: if ; then CAS_SRC_LOG="/var/log/cas_src.log 2>&1" else CAS_SRC_LOG="/dev/null 2>&1" fithen does this: /usr/bin/echo "heartbeat:... (5 Replies)
Discussion started by: jbmorrisonjr
5 Replies

4. UNIX for Dummies Questions & Answers

/dev/null 2>&1 Versus /dev/null 2>1

How are these two different? They both prevent output and error from being displayed. I don't see the use of the "&" echo "hello" > /dev/null 2>&1 echo "hello" > /dev/null 2>1 (3 Replies)
Discussion started by: glev2005
3 Replies

5. Shell Programming and Scripting

Error output of cat to /dev/null

Hello, I'm trying to send the error output of a 'cat' operation to /dev/null like this: cat /dirA/dirB/temp*.log > /dirA/dirB/final.log 2>/dev/null This works perfectly in a terminal, but not when placed in a script. If there are no files matching temp*.log the script outputs an error... (7 Replies)
Discussion started by: Nils88
7 Replies

6. UNIX for Dummies Questions & Answers

cp output /dev/null results in not a directory

Hello, I am working on a script to measure the read performance of a busybox environment. The logical choice is to use a command line like: (time cp * /dev/null) 2> /tmp/howlong.txt Ah, the rub is cp or /dev/null will only accept a single file at a time. The result in the txt file is and... (1 Reply)
Discussion started by: stevesmo
1 Replies

7. Shell Programming and Scripting

/dev/null what is the use of it?

when do you use the path /dev/null (3 Replies)
Discussion started by: webmunkey23
3 Replies

8. Solaris

What is /dev/tty /dev/null and /dev/console

Hi, Anyone can help My solaris 8 system has the following /dev/null , /dev/tty and /dev/console All permission are lrwxrwxrwx Can this be change to a non-world write ?? any impact ?? (12 Replies)
Discussion started by: civic2005
12 Replies

9. Solaris

URGENT - setup port and dump all output to /dev/null or a file

Please help urgently. I need to setup up some sort of service on a solaris server on a port. I dont need it do anything special, anything that is sent to this port from an external server should be dump to /dev/null or a flat file.. Can you help urgently? (1 Reply)
Discussion started by: frustrated1
1 Replies

10. UNIX for Dummies Questions & Answers


Hi , I am importing some table from /dev/null i dont understand what is /dev/null Sorry i am new to UNIX sam71 (3 Replies)
Discussion started by: sam71
3 Replies
Login or Register to Ask a Question