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
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 12:59 AM
Moving file to directory based on condition. ramanagh Shell Programming and Scripting 2 02-02-2008 07:41 AM
Read file based on condition sbasetty Shell Programming and Scripting 5 01-31-2007 10:54 PM
Splitting a file based on some condition and naming them srivsn Shell Programming and Scripting 1 12-07-2005 07:27 AM
awk script to split a file based on the condition superprogrammer Shell Programming and Scripting 12 06-14-2005 12:59 AM

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 05-15-2008
Registered User
 

Join Date: Sep 2007
Posts: 4
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
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 05-15-2008
Registered User
 

Join Date: Jan 2007
Posts: 24
cat file | awk '$4="04" { print $1 $2 $3 $4 }' > new_file
Reply With Quote
  #3 (permalink)  
Old 05-15-2008
rubin's Avatar
Registered User
 

Join Date: Nov 2007
Posts: 146
Quote:
I have a comma separated file with millions of records in it...
Code:
awk -F, '$4=="04"' infile > outfile
Reply With Quote
Google UNIX.COM
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 04:01 AM.


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

Content Relevant URLs by vBSEO 3.2.0