Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 07-31-2014, 08:44 PM   #1
LQ Newbie
Registered: Jul 2014
Posts: 2

Rep: Reputation: Disabled
Combine (cat) all files in a tar.gz file


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.

Old 07-31-2014, 09:01 PM   #2
Senior Member
Registered: Dec 2013
Distribution: Slackware
Posts: 1,982

Rep: Reputation: 491Reputation: 491Reputation: 491Reputation: 491Reputation: 491
Assuming everything goes well try:
tar -O -xf test.tar.gz > singlefile.csv
1 members found this post helpful.
Old 07-31-2014, 09:21 PM   #3
Senior Member
Registered: Sep 2010
Location: Wellington, New Zealand
Distribution: Slackware, Fedora
Posts: 1,024

Rep: Reputation: 665Reputation: 665Reputation: 665Reputation: 665Reputation: 665Reputation: 665
tar xvf myfiles.tar.gz -O > bar

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

Last edited by notKlaatu; 07-31-2014 at 09:23 PM. Reason: ack previous answer
Old 08-01-2014, 03:05 AM   #4
LQ Newbie
Registered: Jul 2014
Posts: 2

Original Poster
Rep: Reputation: Disabled
Ahhh!!! -O Thank you so perfectly....and very elegant!


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
combine multiple files into one file? baddah Linux - Newbie 10 09-06-2011 12:22 PM
Can I combine contents of 2 files into a third file ? mq15 Linux - Newbie 7 02-06-2010 03:48 PM
Combine output of multiple files in one CSV file say_hi_ravi Programming 4 07-17-2008 04:04 AM
Combine multiple wmv files to one large file drkstr Linux - Software 4 04-26-2006 12:50 PM
Command to combine several files as a single file, etc. satimis *BSD 3 06-10-2004 04:59 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 09:49 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration