Solved

AWK and search string

Posted on 2004-08-27
4
651 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 21

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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
nodeip 9 97
Correct syntax to upload file in a script using sftp 2 109
Sed question 2 139
replace content of certain columns in a *.csv file by a defined string 12 89
This tech tip describes how to install the Solaris Operating System from a tape backup that was created using the Solaris flash archive utility. I have used this procedure on the Solaris 8 and 9 OS, and it shoudl also work well on the Solaris 10 rel…
I promised to write further about my project, and here I am.  First, I needed to setup the Primary Server.  You can read how in this article: Setup FreeBSD Server with full HDD encryption (http://www.experts-exchange.com/OS/Unix/BSD/FreeBSD/A_3660-S…
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.:
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
Suggested Courses

734 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