Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

AWK and search string

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Let's say you need to move the data of a file system from one partition to another. This generally involves dismounting the file system, backing it up to tapes, and restoring it to a new partition. You may also copy the file system from one place to…
FreeBSD on EC2 FreeBSD (https://www.freebsd.org) is a robust Unix-like operating system that has been around for many years. FreeBSD is available on Amazon EC2 through Amazon Machine Images (AMIs) provided by FreeBSD developer and security office…
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 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

715 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