To search a word in particular column using awk


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting To search a word in particular column using awk
# 1  
Old 07-18-2011
To search a word in particular column using awk

I have a data in a file like this


1 praveen bmscollege
2 shishira bnmit
3 parthiva geethamce


I want to search "praveen" using awk command i tried like this but i did not get
awk `$2="praveen" {print $0} ` praveen.lst

can anyone help me solving this problem in simple and clear manner???
# 2  
Old 07-18-2011
Code:
awk '$2~"praveen"' file

# 3  
Old 07-18-2011
Code:
awk '$2=="praveen" ' praveen.lst

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

How to search for a word in column header that fully matches the word not partially in awk?

I have a multicolumn text file with header in the first row like this The headers are stored in an array called . which contains I want to search for each elements of this array from that multicolumn text file. And I am using this awk approach for ii in ${hdr} do gawk -vcol="$ii" -F... (1 Reply)
Discussion started by: Atta
1 Replies

2. Shell Programming and Scripting

How to search for right word using awk?

Hi- I have issue with the code to get the input file reformat --Goal is reformat and print out only column name one per line, leading space or trailing space will be removed... --TABLE1.DDL as input file, and content of file as show below REPLACE VIEW TABLE1 ( ID ,COL1 ... (3 Replies)
Discussion started by: lv99
3 Replies

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

4. Shell Programming and Scripting

How to search for a word in a particular column of a file

How to search for a word like "computer" in a column (eg: 4th field) of a '***' delimited file and add a column at the end of the record which denotes 'Y' if present and 'N' if not. After this, we need to again check for words like 'Dell' but not 'DellXPS' in 5th field and again add another column... (5 Replies)
Discussion started by: Jassz
5 Replies

5. Shell Programming and Scripting

Question on awk for finding the column number using a match word

Hi Guys, Please help me out in my situation of writing a shell script Exampl:I have a output like asnapply 1 2 3 apply_server=1 apply_schema=ASN asnapply 1 2 3 apply_server=2 apply_schema=ASN Now i need output like asnacmd applysever=1 applyschema=ASN stop asnacmd applysever=2... (16 Replies)
Discussion started by: mallak
16 Replies

6. Shell Programming and Scripting

search a word and print specific string using awk

Hi, I have list of directory paths in a variable and i want to delete those dirs and if dir does not exist then search that string and get the correct path from xml file after that delete the correct directory. i tried to use grep and it prints the entire line from the search.once i get the entire... (7 Replies)
Discussion started by: dragon.1431
7 Replies

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

8. Shell Programming and Scripting

AWK seach for exact word in certain column

Can anyone help me how I will extract all lines in a file where the word "worker" or "co-worker" in 2nd column exist. There are also word in 2nd column like "workers" or "worker2" but I don't want to display those lines. Appreciate any help in advance! Thank you! (5 Replies)
Discussion started by: Orbix
5 Replies

9. Shell Programming and Scripting

How can i open a directory and search a word using awk....

Hi guys,I m new one in awk scripting....i want to search a word with in a directory...in that directory haviing many files...if i give a work ,it should open the directory and open each file for to search that particular word....is it possible in awk...tell me guys its really urgent.... (2 Replies)
Discussion started by: stalin2020
2 Replies

10. Shell Programming and Scripting

Word search in awk

If I have data as below : 1,ABC,XXXX 2,ABC000,YYYY 3,DEF,AAAA 4,ABC0,ZZZZ I want to get records whose 2nd col exactly match with word 'ABC' I am using command below : awk -F"," '$2~/ABC/' Filename It is retrieving records as - 1,ABC,XXXX 2,ABC000,YYYY 4,ABC0,ZZZZ But in... (8 Replies)
Discussion started by: videsh77
8 Replies
Login or Register to Ask a Question