LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   awk command to find if any one argument is matching (https://www.linuxquestions.org/questions/linux-newbie-8/awk-command-to-find-if-any-one-argument-is-matching-614162/)

Ashok_mittal 01-17-2008 12:17 AM

awk command to find if any one argument is matching
 
What is the command to find out the lines having a certain word in it.
I have given a command :

awk '{if($1=="ashok")print}' awk.txt

here awk.txt is a file containing differnet lines.
how i amend this command to get every line printed having ashok in any column
like awk.txt file

line1--> ashok mehera 23

line2--> mittal ashok 25

line3--> anand goyal 34


so from the above command only will print line 1 instead i want that both line 1 and line 2 should be printed.

druuna 01-17-2008 12:19 AM

Hi,

awk '/ashok/ { print }' awk.txt should work.

All between / and / is what awk is lookin for in a line, if it finds a hit, the line is printed.

Hope this helps.

Ashok_mittal 01-17-2008 12:38 AM

Quote:

Originally Posted by druuna (Post 3025373)
Hi,

awk '/ashok/ { print }' awk.txt should work.

All between / and / is what awk is lookin for in a line, if it finds a hit, the line is printed.

Hope this helps.


Thanks Buddy it works efficiently


All times are GMT -5. The time now is 12:32 PM.