Operating System - HP-UX
1820172 Members
4114 Online
109620 Solutions
New Discussion юеВ

Re: split a file into 5 files

 
uadm26
Super Advisor

split a file into 5 files

Hi,

I have a log file whith 30 MB
I need to split the into 5 files more smalls
Can you help me?

Thanks, Joel
10 REPLIES 10
Franky_1
Respected Contributor

Re: split a file into 5 files

Hi Joel,

as the name implies - just use the "split" command which splits the original file in different pieces according to your inputs
(see man split for more details)

Regards

Franky
Don't worry be happy
Pete Randall
Outstanding Contributor

Re: split a file into 5 files

Try "split -b 6m ". This should produce 5 files name .aa, .bb, .cc, .dd, .ee.


Pete

Pete
H.Merijn Brand (procura
Honored Contributor

Re: split a file into 5 files

split is the easy (and stupid) way to go. Not that using split is stupid, far from that, but split is very stupid in where to split on.

If you need more control, like having a certain pattern on the line to split on (before/after), use csplit, which takes context into consideration

# man csplit

Enjoy, Have FUN! H.Merijn
Enjoy, Have FUN! H.Merijn
uadm26
Super Advisor

Re: split a file into 5 files

Hi,

only generates a file:

109002 Sep 29 12:40 xaa

Re: split a file into 5 files

What's the problem in using split,very simple way to split file.
Can u try it
regrads
SK
Your imagination is the preview of your life's coming attractions
Stanimir
Trusted Contributor

Re: split a file into 5 files

Hi, Joel !
In fact I have such logs /30-40MB/, but I decide to separate parts of these logs day by day and to keep it detached hierarhy directory day-by-day /year/mount/day/log.

For example: /2004/09/21/system1_20040921.log.
/2004/09/22/system1_20040922.log
and so on.

I'm attaching you my 2 scripts like a tools to do this. 1st of them separated current day part of log of system1 and send them to system2 by ftp. 2nd script organize keeping
logs of system1 in hierarchy, mentioned above,on system2.

Regards,Stan
Muthukumar_5
Honored Contributor

Re: split a file into 5 files

Check file system size there as,

bdf
df

so that do you have enough space to do this operation. It will create new files so that it will occupy memory there in the file system.

cd into another file system which is having more memory there and try as

split -b 6m

so that it will create new files in new directory there only.


Easy to suggest when don't know about the problem!
Cheryl Griffin
Honored Contributor

Re: split a file into 5 files

ASplit might work
http://hpux.cs.utah.edu/hppd/hpux/Text/ASplit-2.03/
"Downtime is a Crime."
Prashant Zanwar_4
Respected Contributor

Re: split a file into 5 files

Hi,

Here is syntax which may help you.

Say your file has 1024bytes, and you want to make five parts of it.

split -b 204 (bytes) filename

this should be making it five parts. and it will be named as xaa xab ...
I have tried it and it works fine. I have devided a file in two pieces and also in 116 parts.

Hope this helps
Prashant
"Intellect distinguishes between the possible and the impossible; reason distinguishes between the sensible and the senseless. Even the possible can be senseless."
Kent Ostby
Honored Contributor

Re: split a file into 5 files

Joel --

How big was the test file you used (file x) ?

If it was less then your split size then its only going to generate one file for you.

Best regards,

Kent M. Ostby
"Well, actually, she is a rocket scientist" -- Steve Martin in "Roxanne"