seaching field and getting complete record


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers seaching field and getting complete record
# 1  
Old 08-28-2006
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  
Old 08-28-2006
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  
Old 08-28-2006
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  
Old 08-28-2006
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  
Old 08-28-2006
thanks a lot...it is working fine
 
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Prepend 0 to a field in a record

Hi All, I have a file like below. In the field 9 I am having 14,014,3,001/009 on the records. I want to convert the field to a three digit value. For example 14 should 014 , 3 should 003 11050;11001;;CREDITTRANC;5293218;NRATL;;;11095;;-1;14;3;29=0000;1.25... (5 Replies)
Discussion started by: arunkumar_mca
5 Replies

2. UNIX and Linux Applications

UNIX spool command not extracting complete record from the Oracle table

Hello All, I'm trying to spool an oracle table data into a csv file on unix server but the complete record is not being extracted. The record is almost 1000 characters but only 100 characters are being extracted and rest of the data getting truncated. I'm setting below options : SET... (4 Replies)
Discussion started by: venkat_reddy
4 Replies

3. Shell Programming and Scripting

Display combination of 4 field uniqe record and along with concatenate 5th and 6th field.

Table ACN|NAME|CITY|CTY|NO1|NO2 115|AKKK|ASH|IND|10|15 115|AKKK|ASH|IND|20|20 115|AKKK|ASH|IND|30|35 115|AKKK|ASH|IND|30|35 112|ABC|FL|USA|15|15 112|ABC|FL|USA|25|20 112|ABC|FL|USA|25|45 i have written shell script using cut command and awk programming getting error correct it and add... (5 Replies)
Discussion started by: udhal
5 Replies

4. Shell Programming and Scripting

Match complete field

hello, i have a little problem, i want match the complete field ($1 or $2) with a complete word in another variable. example: i have a file with either one or two words per lane: hsa-mir-4449 hsa-mir-4707 hsa-mir-4707* hsa-mir-4707 novelMiR_3551 novelMiR_3563 novelMiR_4330... (4 Replies)
Discussion started by: ace13
4 Replies

5. Linux

perl program to delete the complete record

Hi all, I want a perl program to delete the record and its contents from a file if there is no particular line in the record given that all records are separated by a blank line. For example: #100 abcd efgh hijk 123 klm #200 abcd efgh hijk klm So, the pattern here is 123. If... (0 Replies)
Discussion started by: kaav06
0 Replies

6. Shell Programming and Scripting

using field 2 in file2 to complete field 3 in file1

Hello, I was hoping someone could help me with this work related problem... basically what I want to do is the following: file2: 1 o 2 t 4 f 5 v 7 n 8 e 10 a file1: 1 : (8 Replies)
Discussion started by: smarones
8 Replies

7. Shell Programming and Scripting

awk to print field no 10 and complete event

hi, awk -F ";" '{if($10>500) then i++; } END{print i}' event_file_FR12_202_24-11-2009_* | less How to modify and add to this above to print the complete line in less ex : 4712714002021527;15298888;241129 095614... (1 Reply)
Discussion started by: madfox
1 Replies

8. Shell Programming and Scripting

get a field from a record

I have a file as: A,B,C,D,E G,H,I,J,K I need to find if fourth field is blank or has a space and print that line to other file. I tried using awk but am not getting the desired result. Pls help. (6 Replies)
Discussion started by: praveenK_Dudala
6 Replies

9. UNIX for Dummies Questions & Answers

To output complete record with JOIN

Hi I have 2 files file1 12312341231612634 34534368463786347 23472364287687263 23472357841007237 file2 12123561235176351*dhfsdhfh*2347623462*sdfjshehweu*123651235*sdgfsgfsy*23237346* 23472357841007237*defsjdf*12378234*hsdhfsdhgfsh*12837238947*dsjshgdfs*2348972348*... (1 Reply)
Discussion started by: unxusr123
1 Replies
Login or Register to Ask a Question