Search on a particular column


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Search on a particular column
# 1  
Old 07-06-2009
Search on a particular column

Hi Guys,

I like to search on a particular column for a string.
This is my file

503018," 215/55HR18 BSW","Y"," ",20080204,20080204," ","T2456GH"
503019," 215/60HR17 BSW","Y"," ",20080204,20080204," ","T2456GH"
503020," 225/55R19 BSW","Y"," ",20080204,20080204," ","T2456GH"
505023," 225/60R18 BSW","Y"," ",20080409,20080410," ","T2456GH"
503021," 225/65R16 BSW","Y"," ",20080204,20080204," ","T2456GH"
503022," 225/65R17 BSW","Y"," ",20080204,20080204," ","T2456GH"
477513," 225/70R19.5 BSW","Y"," ",20041027,20080227," ","T2456GH"
505022," 245/45R20 BSW","Y"," ",20080409,20080410," ","T2456GH"
506344," 245/45ZR20 BSW","Y"," ",20080617,20080619," ","T2456GH"

I want to search on the 3rd column for "N" value.

i tried this..but it was not giving me the desired output as i changed the N to Y to check whether it is working or not.

nawk -F "," ' $3 == "Y" ' Src_NPI_eznndsc_intial.unl

I also tried this..
awk '$3 ~ /"N"/' Src_NPI_eznndsc_intial.unl


Please correct me where i went wrong..

Thanks for the help in advance,,

Regards,
Magesh
# 2  
Old 07-06-2009
Try this,

nawk -F',' '$3 == "\"N\"" { print }' <Filename>
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Search and retrieve the next Column.

Hi Guys, I have a File like below. FTOP,1|NOME,5|SERP,3 SERP,4|FTOP,7|POSE,4 Now, i am able to separate using multiple Delimiters in Awk. So,now when i search for FTOP, i need to retrieve the next column. In the above case, 1 7 Can somebody help as how to retrieve it. ... (2 Replies)
Discussion started by: mac4rfree
2 Replies

2. Shell Programming and Scripting

awk search pattern in column

Want to search a pattern in column using the below command which not helpful awk -F"\|" '$1 == '"${VAR}"' {print $1,$2}' file how to search using "==" with variable other than the below case. awk -F"\|" '$1 ~ /'"${VAR}"'/ {print $1,$2}' file (14 Replies)
Discussion started by: Roozo
14 Replies

3. Shell Programming and Scripting

Search substring in a column of file

Hi all, I have 2 files, the first one containing a list of ids and the second one is a master file. I want to search each id from the first file from the 5th col in the second file. The 5th column in master file has values separated by ';', if not a single value is present. Each id must occur... (2 Replies)
Discussion started by: ritakadm
2 Replies

4. UNIX for Dummies Questions & Answers

Search word in 3rd column and move it to next column (4th)

Hi, I have a file with +/- 13000 lines and 4 column. I need to search the 3rd column for a word that begins with "SAP-" and move/skip it to the next column (4th). Because the 3rd column need to stay empty. Thanks in advance.:) 89653 36891 OTR-60 SAP-2 89653 36892 OTR-10 SAP-2... (2 Replies)
Discussion started by: AK47
2 Replies

5. Shell Programming and Scripting

Column Search and Line Removal

Hello Gurus, I need to remove lines within a file if it contains specific criteria. Here is what I am trying to resolve: Users of AppRuntime: (Total of 10 licenses issued; Total of 6 licenses in use) buih02 dsktp501 AppGui 1 (compute_lic/27006 3122), start Mon 2/22 7:58 dingj1... (3 Replies)
Discussion started by: leepet01
3 Replies

6. Shell Programming and Scripting

AWK in column search

Hi friends , I am new to unix ,need your help to fix this there is a ~ deliminated file. how to find the 5th column of the row. awk 'print $5 ' abc.txt it doesnot work . it works for table deliminated file. My data file is like the following manner. abc.txt -------- a~b~c~d~e~f... (3 Replies)
Discussion started by: imipsita.rath
3 Replies

7. Shell Programming and Scripting

Search in a column by a string

Hi All, My file looks like : hsdhj dsajhf jshdfajkh jksdhfj jkdhsfj shfjhd shdf hdsfjkh jsdfhj hdshf sdjh dhs foot dsjhfj jdshf dasfh jdsh dsjfh jdfshj david Now, I want to search entire column by a string... (10 Replies)
Discussion started by: naw_deepak
10 Replies

8. Shell Programming and Scripting

Search for a column by name in awk

Hi, I have a file that has many columns. Let us say "Employee_number" "Employee_name" "Salary". I want to display all entries in a column by giving all or part of the column name. For example if I input "name" I want all the employee names printed. Is it possible to do this in a simple manner... (2 Replies)
Discussion started by: kskkarthik
2 Replies

9. Shell Programming and Scripting

Can SED Search By Column?

Hi all, I am trying to search for a keyword in the fourth column of a massive carrot(^) delimited file and unfortunately I cannot use AWK (which would have been ideal). Can SED (or maybe even GREP) perform a search like this? (12 Replies)
Discussion started by: Korn0474
12 Replies

10. Shell Programming and Scripting

column based search

Hi, I need to search one file based on the entry from another; eg. file1 has entries; 45654 34768 12345 File2 has entries 23234 somestring 4312 45654 somestring 34768 12345 somestring 45654 so I need to pick first entry in file1 which eg. '45654' and... (8 Replies)
Discussion started by: user_007
8 Replies
Login or Register to Ask a Question