LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Combine (cat) all files in a tar.gz file (https://www.linuxquestions.org/questions/linux-newbie-8/combine-cat-all-files-in-a-tar-gz-file-4175512910/)

mdavisuk 07-31-2014 07:44 PM

Combine (cat) all files in a tar.gz file
 
Hi,

Sorry if this is a an easy question but its go me beat at the mo after lots of trying.

I have a test.tar.gz file that contains 100 csv files.

I'm trying to work out how to unzip and extract all the files and cat them all together into 1 single csv file in one or possibly 2 commands...and leaving me with just the one csv file as the output...not all the extracted ones as well/

I *think* i need something like:

tar -xvf test.tar.gz | cat *.csv > singlefile.csv

but obviously this isn't correct .

I've played around for ages now with lots of variations and using "-" as well but the best I managed was to extract all the files AND create the singlefile as well....when what i need as the only output is a singlecsv file that contains all the lines within the 100 csv files.

Many thanks for any help or pointers.

Mike

metaschima 07-31-2014 08:01 PM

Assuming everything goes well try:
Code:

tar -O -xf test.tar.gz > singlefile.csv

notKlaatu 07-31-2014 08:21 PM

Code:

tar xvf myfiles.tar.gz -O > bar

edit:
...and I see that metaschima posted while I was typing! beat me to it.

mdavisuk 08-01-2014 02:05 AM

Ahhh!!! -O Thank you so much.....works perfectly....and very elegant!
Mike


All times are GMT -5. The time now is 03:37 PM.