Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I guess a lot of people are or were used to:

  tar -xzf file.tar.gz
To be honest, I only started doing -xf a year ago. I was used to -xjf and -xzf.


tar flags must be a prime example of cargo culting. Hands up everyone who's done or seen someone do

  tar -xzvf file.tgz > /dev/null


never seen that in my life until now - what does it do? Just unzip the file to dev/null? What's the purpose? Does the verbose flag show you what's inside but the dev/null means it's not written to disk while unzipping?


Actually, the files are decompressed to the current directory, it's the just output of the verbose flag that goes to /dev/null. Which makes is even more senseless.


Exactly. I've seen people who always do `tar xzvf` and have no idea removing the `v` is the correct way to make it not print the name of every file in the archive.


I use the -v switch since I want to see what I decompress, however I didn't knew that I could supress the z switch.


You didn't use to be able to suppress the 'z' switch. You had to specify 'z' or 'j' depending on whether you wanted gzip or bzip2 decompression. It's a somewhat recent (sometime in the last 15 years, I think) change to "tar" to make it just detect the compression algorithm.


Isn't it better though to omit the -v switch and do `ls *` and/or `tree` afterwards? That gives you the same information but structured so it's much easier to understand.


The advantage of -v is that you can see what is being extracted as it happens. This is useful if you have a tarball with thousands of small files, as otherwise it's hard to tell whether tar has got stuck or there are just a lot of files.


I don't understand why you'd do that. tar does not compress to stdout.


Redirecting stdout is to cancel the -v flag (verbose, lists every file extracted).




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: