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

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 05-15-2008
Registered User
 

Join Date: Sep 2007
Posts: 14
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  
Old 05-15-2008
Registered User
 

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

Join Date: Nov 2007
Posts: 215
Quote:
I have a comma separated file with millions of records in it...
Code:
awk -F, '$4=="04"' infile > outfile
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 07:33 PM.


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