Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

AWK and search string

Posted on 2004-08-27
4
Medium Priority
?
654 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 21

Accepted Solution

by:
tfewster earned 2000 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: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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

In tuning file systems on the Solaris Operating System, changing some parameters of a file system usually destroys the data on it. For instance, changing the cache segment block size in the volume of a T3 requires that you delete the existing volu…
Why Shell Scripting? Shell scripting is a powerful method of accessing UNIX systems and it is very flexible. Shell scripts are required when we want to execute a sequence of commands in Unix flavored operating systems. “Shell” is the command line i…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
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.:
Suggested Courses
Course of the Month6 days, 18 hours left to enroll

782 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