Solved

AWK and search string

Posted on 2004-08-27
4
648 Views
Last Modified: 2010-05-18
still can't get this command right.


I need to find a string that is always in the 6th or 7th column
this string must have all the words in it with one word that can be any word  (xxxx)

ex:

pop.xxxx.my.domain.com

I want to make it to search the 6th and 7th column but can only make is search one or the other

Ex  
awk '$6,  or  awk '7$

I've tried    $6-$7   $6, $7  and with brackets and everything else i can think of, i know it's a easy fix for this part but can't get it.

I'm useing

awk '$7 ~ /.*@pop\..*+.my.domain.com/ {print $6, $7;}'  

Thanks







0
Comment
Question by:bt707
  • 2
4 Comments
 
LVL 45

Expert Comment

by:sunnycoder
ID: 11912831
Hi bt707,

awk ' { print $6 " " $7 } ' input_file | grep "my_search_string"

Sunnycoder
0
 
LVL 20

Accepted Solution

by:
tfewster earned 500 total points
ID: 11914277
Use "||" for "or" in the awk comparision syntax
e.g.
echo pop.xxxx.my.domain.com | awk -F"." '$2 ~ /xxxx/ || $3 ~ /xxxx/'
0
 

Author Comment

by:bt707
ID: 11914492
Thanks sunnycoder,

Just what I need needed,

I ended up using  

awk ' /.*@pop\..*+.oilfield.slb.com/ {print $6, $7;}'  searchfile1

is there a advantage to using awk and then using grep to pull the string

Thanks Agian
0
 

Author Comment

by:bt707
ID: 11914513
Thanks tfewster, thats what i was looking for, how to use this with awk

Thanks
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Attention: This article will no longer be maintained. If you have any questions, please feel free to mail me. jgh@FreeBSD.org Please see http://www.freebsd.org/doc/en_US.ISO8859-1/articles/freebsd-update-server/ for the updated article. It is avail…
A metadevice consists of one or more devices (slices). It can be expanded by adding slices. Then, it can be grown to fill a larger space while the file system is in use. However, not all UNIX file systems (UFS) can be expanded this way. The conca…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now