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 here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Splitting file based on number of rows wahi80 Shell Programming and Scripting 2 06-03-2008 06:38 PM
Splitting a file based on the records in another file er_ashu Shell Programming and Scripting 2 05-12-2008 01:34 PM
Splitting text file to several other files using sed. JeffV Shell Programming and Scripting 3 03-14-2008 12:34 PM
Splitting av file in 2 at specific place based on textpattern borgeh Shell Programming and Scripting 0 09-24-2007 04:02 PM
Splitting a file based on some condition and naming them srivsn Shell Programming and Scripting 1 12-07-2005 08:27 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 01-30-2006
Registered User
 

Join Date: Jan 2006
Posts: 3
splitting files based on text in the file

I need to split a file based on certain context inside the file. Is there a unix command that can do this? I have looked into split and csplit but it does not seem like those would work because I need to split this file based on certain text. The file has multiple records and I need to split this file by lookiing at a certain field and the value of this field changes often. I would appreciate any help on this.
Reply With Quote
Forum Sponsor
  #2  
Old 01-30-2006
Ygor's Avatar
Moderator
 

Join Date: Oct 2003
Location: -31.96,115.84
Posts: 1,249
Awk is the obvious choice. For example, read infile and create outfile.1, outfile.2, etc....
Code:
awk 'BEGIN{cnt=1}(condition){cnt++}{print $0 > "outfile." cnt}' infile
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 08:55 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0