![]() |
|
|
|
|
|||||||
| 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 |
| How to parse through a file and based on condition form another output file | sivasu.india | UNIX for Advanced & Expert Users | 6 | 02-28-2008 01:59 AM |
| Moving file to directory based on condition. | ramanagh | Shell Programming and Scripting | 2 | 02-02-2008 08:41 AM |
| Read file based on condition | sbasetty | Shell Programming and Scripting | 5 | 01-31-2007 11:54 PM |
| Splitting a file based on some condition and naming them | srivsn | Shell Programming and Scripting | 1 | 12-07-2005 08:27 AM |
| awk script to split a file based on the condition | superprogrammer | Shell Programming and Scripting | 12 | 06-14-2005 12:59 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Spliting file based on condition
Hi,
I have a comma separated file with millions of records in it. I have a requirement to split the file based on the value in a one of the columns. Suppose i have a text file with columns like C1, C2,C3,C4 Column C4 can hold the values either 01 or 02 03 or 04. I nned to extract the records which are having C4=04 into a separate file. Could i get any help on this? Many Thanks, Raam |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
cat file | awk '$4="04" { print $1 $2 $3 $4 }' > new_file
|
|
#3
|
||||
|
||||
|
Quote:
Code:
awk -F, '$4=="04"' infile > outfile |
||||
| Google The UNIX and Linux Forums |