Technology

#How to List or Search for Files in a .tar / .tar.gz Archive – CloudSavvy IT

“#How to List or Search for Files in a .tar / .tar.gz Archive – CloudSavvy IT”

Bash Shell

If you have a huge tar backup file and you need to grab some files out of it, wouldn’t it be easier if you can look inside first? Luckily there’s an easy option to do so.

Simply use the -t option to list the contents of the archive because that letter says “list” to everybody and it’s so easy to remember. Yeah. Combine with the -f option to specify the tarfile that you’re getting the list from.

tar -tf tarfile

Of course just using that option will list the entire contents of the archive file, which is gonna be a lot. You can always pipe that through grep to find what you are looking for, but you can also pass a file name as an argument.

tar -tf tarfile filename

Alternatively you can use the wild cards argument to search through the archive for everything matching a pattern. For instance, to find every PNG image in an archive you can use the following command:

tar -tf tarfile --wildcards '*.png'

As mentioned before, you could also use grep to accomplish the same thing, of course. The difference is that the wildcard command is a little more efficient at the cost of having less power.

tar -tf tarfile | grep ".png"

And thus ends the story of how a single letter command line argument turned into an article that you read.

If you liked the article, do not forget to share it with your friends. Follow us on Google News too, click on the star and choose us from your favorites.

For forums sites go to Forum.BuradaBiliyorum.Com

If you want to read more like this article, you can visit our Technology category.

Source

Related Articles

Leave a Reply

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

Back to top button
Close

Please allow ads on our site

Please consider supporting us by disabling your ad blocker!