LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 01-17-2008, 12:17 AM   #1
Ashok_mittal
Member
 
Registered: Dec 2007
Posts: 73

Rep: Reputation: 15
Cool 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.
 
Old 01-17-2008, 12:19 AM   #2
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
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.
 
Old 01-17-2008, 12:38 AM   #3
Ashok_mittal
Member
 
Registered: Dec 2007
Posts: 73

Original Poster
Rep: Reputation: 15
Thumbs down

Quote:
Originally Posted by druuna View Post
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
 
  


Reply



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Find/grep command to find matching files, print filename, then print matching content stefanlasiewski Programming 9 06-30-2016 05:30 PM
awk help - matching uttam_h Programming 7 10-17-2007 02:20 PM
"argument list too long" - why am I getting this with the find command laggerific Linux - Software 11 10-01-2007 12:01 PM
sed/awk for matching & substituition laikos Programming 3 11-22-2006 11:44 AM
awk: /matching/ variables passed with -v aunquarra Linux - General 2 02-17-2005 06:47 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 12:46 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration