LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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!

Notices


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

Rep: Reputation: Disabled
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
 
Old 07-31-2014, 08:01 PM   #2
metaschima
Senior Member
 
Registered: Dec 2013
Distribution: Slackware
Posts: 1,982

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

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

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

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

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


Reply



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 11:22 AM
Can I combine contents of 2 files into a third file ? mq15 Linux - Newbie 7 02-06-2010 02:48 PM
Combine output of multiple files in one CSV file say_hi_ravi Programming 4 07-17-2008 03:04 AM
Combine multiple wmv files to one large file drkstr Linux - Software 4 04-26-2006 11:50 AM
Command to combine several files as a single file, etc. satimis *BSD 3 06-10-2004 03:59 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 06:32 PM.

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