spliting 4gb files to 4*1 gb each


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting spliting 4gb files to 4*1 gb each
# 1  
Old 07-05-2008
spliting 4gb files to 4*1 gb each

I have log file whose size is 4 GB , i would like to split it to 1 gb each ,Can any one tell me the syntax of csplit comand for that.

I am using Sun0S 5.8
# 2  
Old 07-05-2008
Based on your description, it would seem that split is more appropriate. Csplit splits a file based on context whereas split split it based on linecount or size.

> split -b 1024m <file> <split-name>

> split -b 1024m reallybigfile smallfile
should give you files smallfileaa, smallfileab, smallfileac and smallfilead
# 3  
Old 07-05-2008
I just saw another post of yours that concerned a problem opening large files. Based on that, I'm going to assume that you will process the log file in these split pieces. If so, you need to split it based on line count.

You can use split or csplit. To determine the line count for the split files, first determine how many lines are in the logfile. You could form an expression to have the shell do the calculation and give you the final number but I won't bother with that here since I don't know which shell you use and you only asked for syntax.

> wc -l logfile
Whatever number is returned, divide by 4 and round up.

Let's say that logfile has 7607255 lines. Diving and rounding gives you approximately 1901814 lines per split-file.

Using split:
> split -1901814 biglogfile splitfile
will give you splitfileaa, splitfileab, splitfileac and splitfilead.


Using csplit:
> csplit -k -f csplitfile biglogfile 1901814 {2}
will give you csplitfile00, csplitfile01, csplitfile02 and csplitfile03.

In this case, I don't think the -k is really necessary but it doesn't hurt to include it just in case some error is encountered. On my system, the first file generated by csplit actually has 1 less line in it.


Whichever method you use, unless there is some anomaly with your log file, the file sizes should be pretty close to 1GB in size.
# 4  
Old 07-06-2008
Thank you all for this Info. -- It is working.

I need some more info on rebuilding my Perl binary.
In my dev i am able to read a 4gb file using perl script --but same script failed in Prod.

When I am typing perl -V in development Env (SAME OS as Prod but different Perl build options and version ) it show -information like

Compile-time options:
USE_64_BIT_INT USE_ITHREADS USE_LARGE_FILES
also showing ----

uselargefiles=define
config_args=-Duse64bitint
--- ----

But when i am typing the same perl -V in production --the use LARGE FILE options is not showing ?

I know if i will rebuild with -DLARGE_FILE options or uselargefiles=define then i can open a file of 4 GB,But not sure how to set this parameter in perl and where to set ?

Aalso if i need to rebuild the perl binary -will the existing setup be disturbed ???
Any idea will help me.

Last edited by jambesh; 07-06-2008 at 02:51 PM.. Reason: mistake in earlier post
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

32 bit process addressing more than 4GB

Hello for all, I am testing the behavior of a 32 bit application running on Solaris 5.10 (SPARC), and realize it reaches 4GB of memory and then crashes. It doesn't matter the amount of used memory as application is intended to perform many transactions; rather, what I want to achieve is to... (2 Replies)
Discussion started by: Leito7824
2 Replies

2. UNIX for Dummies Questions & Answers

7z command for files larger than 4GB ( unzip doesn't work)

My unzip command doesn't work for files that are greater than 4GB. Consider my file name is unzip -p -a filename.zip, the command doesn't work since the size of the file is larger. I need to know the corresponding 7z command for the same. This is my Unix shell script program: if then ... (14 Replies)
Discussion started by: chandraprakash
14 Replies

3. AIX

Fork Function Failed on 4GB ?

Hello, I am running Oracle Database and after a while I keep getting this message whenever I execute any command. I cannot execute any command even shutdown, whenever I execute any command , I get this message /usr/bin/ksh: 0403-031 The fork function failed. There is not enough memory... (7 Replies)
Discussion started by: filosophizer
7 Replies

4. Linux

Need assistance to enable more that 4GB RAM on Linux 32Bit OS.

How to enable more than 4GB RAM support on Linux 32bit OS? OS: CentOS release 5.4 (Final) Kernel version: 2.6.18-53.el5 Arch: 32Bit I got solution at Innovationframes.com &bull; View topic - How to enable more than 4GB RAM support on Linux 32bit OS? but my question is the steps given... (5 Replies)
Discussion started by: chandranjoy
5 Replies

5. UNIX for Dummies Questions & Answers

Spliting of two files

hi I have a log file which contains some reports. The log file looks like this:- STARTOFREPORT /tmp file1.txt some text to be folowd ENDOFREPORT some non utilized characters STARTOFREPORT /log file2.txt more text (3 Replies)
Discussion started by: infyanurag
3 Replies

6. UNIX for Dummies Questions & Answers

How to copy my system hdd usb stick from 4GB to 8GB ?

Hi, my router is my Linux embedded device. I have system installed on HDD 4GB usb stick, part1 swap, part2 /opt , part3 data. I need to copy my system to new HDD 8GB usb stick. What is a way for 4GB > 4GB HDD and what for 4GB > 8GB As I remeber, I can copy image of my 4GB HDD usb stick... (7 Replies)
Discussion started by: jack2
7 Replies

7. IP Networking

4GB Dual Port HBA

I have one 4GB, dual port HBA. Is each port rated for 4GB, or is it the whole HBA rated for 4GB? Also, how do I determine which is port0 / port1 with "lscfg -vl fcs0" command. Thanks. (0 Replies)
Discussion started by: jwholey
0 Replies

8. AIX

fiber with 4GB

Hi, It's my first time I will use a 4BG fiber with two ports on one card. I used only one port 2GB before. What will be the drivers I need to install on my AIX5.3? Is the two ports going to be just one line? Or I can use the other ports on another connection. Thanks in advance, itik (1 Reply)
Discussion started by: itik
1 Replies

9. Shell Programming and Scripting

Help on Spliting files - urgent

Hi Script Masters I have a strange requirement. Please help. I am using C shell. I have a file like the below in sorted order 22 23 25 34 37 45 67 342 456 476 543 677 789 Now I have to split the file in such a way that first 5 of 2 digit number should be saved as aaa.in and the... (8 Replies)
Discussion started by: rajee
8 Replies
Login or Register to Ask a Question