LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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 08-17-2015, 01:22 PM   #1
Haba2015
LQ Newbie
 
Registered: Mar 2015
Posts: 10

Rep: Reputation: Disabled
How to Split a large file according to the same aggregated files


Hi Everyone,

I have aggregated some files (>100) using:

cat *.txt >> bigfie.txt

Now I want to split this big file according to the original or individual filenames. I want my files back according to former filenames.

I have the file names in x*** when I do:

split bigfile.txt ~/path/newfiles/

Please help!!!
 
Old 08-17-2015, 01:27 PM   #2
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fedora-35
Posts: 5,313

Rep: Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918
what does bigfie.txt look like. is there any type of delimiter (or were the original files all the same length) ?

else there is no way to know where the original files begin (it'll be like getting pee out of a pool).
 
Old 08-17-2015, 01:28 PM   #3
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 10,005

Rep: Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191
Unless you have some way of identifying, within the bigfile.txt, where a file's contents begin and start I would think your pretty buggered. As far as I am aware cat will not
have placed any delimiters in the file.

Are you able to provide any more information on whether or not you have any way to tell where data starts and stops?
 
Old 08-17-2015, 01:49 PM   #4
Haba2015
LQ Newbie
 
Registered: Mar 2015
Posts: 10

Original Poster
Rep: Reputation: Disabled
Thanks Grail and schneidz

The files are based on 6hourly precipitation format. For example, they are in this format:

2015010106.txt
2015010112.txt
2015010118.txt
.
.
.
.
2015033018.txt

where first three files stand for 2015 Jan 1(2015/01/01), 6 UTC, 12 UTC, 18 UTC respectively. I did aggregate them together to perform some overall verification analysis. For space sake, I deleted individual files. Mistake!

Now I need to split this again, and later subset according to each UTC.
 
Old 08-17-2015, 01:53 PM   #5
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fedora-35
Posts: 5,313

Rep: Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918
are you saying the lines can be differentiated by the timestamp ?

then maybe loop thru the file and grep out based on timestamp.
 
Old 08-17-2015, 02:03 PM   #6
Haba2015
LQ Newbie
 
Registered: Mar 2015
Posts: 10

Original Poster
Rep: Reputation: Disabled
Thanks. I have tried to do that:

For example to extract 6UTC,

grep 2015????06 bigfile.txt>only6UTC.txt

did noting. Help would be appreciated.
 
Old 08-17-2015, 07:47 PM   #7
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,120

Rep: Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120
You are presuming the data has the format as the filename - or contains the (original) filename. Pretty big assumption. Lets see the first 20 lines - presuming common data format in the initial files.
Code:
head -n 20 bigfile.txt

Last edited by syg00; 08-17-2015 at 07:50 PM. Reason: filename
 
  


Reply

Tags
awk regex, cat, linux, split



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
Split large file into smaller files mikes88 Programming 29 03-22-2012 10:14 AM
[quick] trying to split a large file but linux says it's to large steve51184 Linux - General 16 05-06-2008 07:40 AM
Split large file in several files using scripting (awk etc.) chipix Programming 14 10-29-2007 11:16 AM
Split a large file and get the names of output files using Perl Sherlock Programming 25 02-02-2007 12:43 PM
Split Large Very Files (Software) kolmogorov Solaris / OpenSolaris 5 11-18-2005 11:46 AM

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

All times are GMT -5. The time now is 11:55 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