The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
How to split pipe delimited file njgirl Shell Programming and Scripting 4 06-18-2008 06:15 PM
Help needed in removing intermediate segments from a pipe delimited segment file naren_0101bits Shell Programming and Scripting 3 12-03-2007 11:54 AM
how to extract a tilde delimited file in unix trichyselva Shell Programming and Scripting 12 03-06-2007 12:19 AM
Grep for NULL in a pipe delimited file sureshg_sampat Shell Programming and Scripting 5 11-21-2006 06:15 AM
Converting Tab delimited file to Comma delimited file in Unix charan81 Shell Programming and Scripting 22 01-20-2006 09:24 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 03-19-2007
ddedic ddedic is offline
Registered User
  
 

Join Date: Mar 2007
Posts: 7
splitting a pipe delimited file in unix

Could one of you shad some light on this:

I need to split the file by determining the record count and than splitting it up into 4 files. Please note, this is not a fixed record length but rather a "|" delimited file.

I am not sure as how to handle reminder/offset for the 4th file.
For example:

"$1|wc -l" /4 + reminder

Please let me know.
  #2 (permalink)  
Old 03-20-2007
matrixmadhan matrixmadhan is offline Forum Advisor  
Technorati Master
  
 

Join Date: Mar 2005
Location: leaf node in B+ tree
Posts: 2,957
looking for split command

if not

please post sample input and output
  #3 (permalink)  
Old 03-20-2007
ddedic ddedic is offline
Registered User
  
 

Join Date: Mar 2007
Posts: 7
Question unix script to split file

My file for ex. is a 10mil record file. Within the shell script I need to determine the record count and divided it into 4 separate files.

Is it ok to do a wc -l into a variable / 4? Would reminder take care of itself - meaning it will be a part of the 4th file.

Please advise and I hope this helps.
  #4 (permalink)  
Old 03-20-2007
matrixmadhan matrixmadhan is offline Forum Advisor  
Technorati Master
  
 

Join Date: Mar 2005
Location: leaf node in B+ tree
Posts: 2,957
Code:
split -l $(( $( wc -l < filename ) / 4)) filename
  #5 (permalink)  
Old 03-20-2007
ddedic ddedic is offline
Registered User
  
 

Join Date: Mar 2007
Posts: 7
thank you matrixmadhan. I will try this one first thing tomorrow morning.

Thank you again.
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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




All times are GMT -4. The time now is 01:59 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0