![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| 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 |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
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.
|
| Forum Sponsor | ||
|
|
|
#2
|
||||
|
||||
|
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
|
||||
| Google The UNIX and Linux Forums |