Geeks Talk

Prepare for your Next Interview


Welcome to the Geeks Talk forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact us.

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 file into 7 ...

Go Back   Geeks Talk > Operating Systems > Unix/Linux
Register Blogs FAQ Tag Cloud Calendar Mark Forums Read
  #1 (permalink)  
Old 06-16-2007
Expert Member
 
Join Date: Oct 2006
Posts: 689
Thanks: 0
Thanked 53 Times in 44 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

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 On
HTML code is On
Trackbacks are On
Pingbacks are On
Refbacks are Off


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 07:58 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.3.1
Copyright © 2009 GeekInterview.com. All Rights Reserved