The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
how to read record by record from a file in unix raoscb UNIX for Dummies Questions & Answers 1 05-16-2008 06:30 AM
splitting a record and adding a record to a file rsolap Shell Programming and Scripting 1 08-13-2007 01:58 PM
how to replace field for each record happyv Shell Programming and Scripting 12 06-26-2007 07:56 AM
modify a few field of the record information happyv Shell Programming and Scripting 11 03-23-2007 01:46 PM
Moving Part of a field to another field using AWK rjsha1 Shell Programming and Scripting 5 08-04-2006 05:39 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 08-28-2006
mahabunta mahabunta is offline
Registered User
  
 

Join Date: Aug 2006
Posts: 45
seaching field and getting complete record

hi, I have a file.....

1|3|4|5|6
1|3|4|4|5

now i ahave to search for value 4 in forth field and write that output to a file.

if i do grep 4 file1 both lines are coming to output.

can somebody help me building command.

thanks and regards
sandeep
  #2 (permalink)  
Old 08-28-2006
ranj@chn ranj@chn is offline Forum Advisor  
Playing with Ubuntu Now!
  
 

Join Date: Oct 2005
Location: Chennai
Posts: 365
awk again

Code:
awk -F'|' ' $4=="4" ' inputfilename > outputfilename
You posted a similar question in the other forum. Try to be patient enough for your answer.
  #3 (permalink)  
Old 08-28-2006
mahabunta mahabunta is offline
Registered User
  
 

Join Date: Aug 2006
Posts: 45
thanks,

I have one more doubt...can your command can be used like...

awk -F ":" ' $1=="$file_fmt_id" ' file2 > schema_id_file_test

where file_fmt_id is variable.

thanks and regards
  #4 (permalink)  
Old 08-28-2006
ranj@chn ranj@chn is offline Forum Advisor  
Playing with Ubuntu Now!
  
 

Join Date: Oct 2005
Location: Chennai
Posts: 365
use awk variables

Change it like this

Code:
awk -F ":"  -v awk_var="$file_fmt_id" ' $1==awk_var ' file2 > schema_id_file_test
  #5 (permalink)  
Old 08-28-2006
mahabunta mahabunta is offline
Registered User
  
 

Join Date: Aug 2006
Posts: 45
thanks a lot...it is working fine
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 07:53 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0