Geeks Talk

Prepare for your Next Interview




SPLIT command

This is a discussion on SPLIT command within the Unix/Linux forums, part of the Operating Systems category; Hi All I have a file that has over 5,00,000 records and I want to split the file into 65,500 rows. I am able to split the ...


Go Back   Geeks Talk > Operating Systems > Unix/Linux

Register FAQ Members List Calendar Mark Forums Read
  #1 (permalink)  
Old 06-16-2007
Expert Member
 
Join Date: Oct 2006
Posts: 690
Thanks: 0
Thanked 49 Times in 41 Posts
JobHelper is on a distinguished road
SPLIT command

Hi All

I have a file that has over 5,00,000 records and I want to split the file into 65,500 rows.

I am able to split the file into 7 files using SPLIT command. I want to know if it is possible to attach a header for all the 7 files using a single script or a single command along with the SPLIT command. Help would be very much appreciated.


Thanks
Sharath
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 06-26-2007
Junior Member
 
Join Date: Jun 2007
Location: Argentina
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
mdk69 is on a distinguished road
Re: SPLIT command

you can use -lnumber to tell split how many rows (or record if a row is a record) will be each file.

split -l65000 mi_huge_file_500000

after that split will create the files xaa, .... etc...
if you want to put a header on each file create the header file and later do a cat on the following way:

cat xaa >> header_file

will append xaa to the header file, but becareful if you want to use the same header, you must replicate it, so you don't lose it.
En fin... try with a script something more elaborated...
I recommend you the advanced bash scripting guide
http://www.tldp.org/LDP/abs/abs-guide.pdf

HTH
Reply With Quote
Reply

  Geeks Talk > Operating Systems > Unix/Linux


Thread Tools
Display Modes


Similar Threads

Thread Thread Starter Forum Replies Last Post
Can i use substring function to split the second column Geek_Guest Data Warehousing 0 04-10-2007 02:06 PM
How to split this entire row's contents into separate strings JobHelper SilkTest 0 01-03-2007 05:32 PM
What is the command StephenRaj Unix/Linux 1 08-20-2006 01:15 AM
Difference between split and csplit sripri Unix/Linux 2 07-26-2006 05:02 PM
Help me with the command joel SQL 1 07-23-2006 12:29 PM


All times are GMT -4. The time now is 01:45 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Copyright © 2008 GeekInterview.com. All Rights Reserved