Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HP-UX - How can I read a text file from tar archive without extracting it?

I have a tar archive which contains several text files. I would like to write a script to display (stdout) the content of a file without extracting it to the current directory.

Actually I would like to do the same as:

tar tf myArchive.tar folder/someFile.txt
cat folder/someFile.txt
rm -R folder

but without the rm...

I tried this way but it didn't work:

tar tf myArchive.tar folder/someFile.txt | cat

Thanks

like image 327
Maxbester Avatar asked Oct 09 '12 14:10

Maxbester


1 Answers

Use x to extract, with f from archive file. Then add also option -O to direct extracted files to standard output.

tar xf myArchive.tar folder/someFile.txt -O
like image 110
Didier Trosset Avatar answered Oct 11 '22 16:10

Didier Trosset