Solved

AWK and search string

Posted on 2004-08-27
4
647 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
Comment Utility
Hi bt707,

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

Sunnycoder
0
 
LVL 20

Accepted Solution

by:
tfewster earned 500 total points
Comment Utility
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
Comment Utility
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
Comment Utility
Thanks tfewster, thats what i was looking for, how to use this with awk

Thanks
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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…
Java performance on Solaris - Managing CPUs There are various resource controls in operating system which directly/indirectly influence the performance of application. one of the most important resource controls is "CPU".   In a multithreaded…
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 get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…

763 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

8 Experts available now in Live!

Get 1:1 Help Now