1752600 Members
4178 Online
108788 Solutions
New Discussion юеВ

Re: Found a word

 
iranzo
Frequent Advisor

Re: Found a word

For Stephenson

We just want lines containing 2/6
Surround ARASW the only characters
are ( and )

Thanks
Bonjour
Muthukumar_5
Honored Contributor

Re: Found a word

Do you want to grep the 2/6 pattern from a file and check for ARASW string enclosed with ()??

# cat file1
2/6 ARASW25 TOTO tutu
(ARASW26) 2/6 TOTO xyz 12/x
tutu yy uu 6/8 ARASW56 titi fff
# grep "2/6" file1 | grep '^(ARASW[^ ]*)'
(ARASW26) 2/6 TOTO xyz 12/x

If it is not the requirement revert with more details.

hth.
Easy to suggest when don't know about the problem!
James R. Ferguson
Acclaimed Contributor

Re: Found a word

Hi Iranzo:

Please try the second solution I posted above. Based on your input, in my opinion, it *does* give you exactly the output for which you asked.

Cut-and-paste the script I posted in my *second* post, name it "perl.pl" and call it like:

# ./perl.pl 2/6 yourfile

The first argument (for example, 2/6, tells that you only want to find lines with this token in them.

Regards!

...JRF...

Muthukumar_5
Honored Contributor

Re: Found a word

Could not understand your requirement in the beginning:(

# grep $MODPORT fic | awk '{ for (i=1;i
hth.
Easy to suggest when don't know about the problem!
Muthukumar_5
Honored Contributor

Re: Found a word

Simpy as,

sed -e "/2\/6/!d;s/.*\(ARASW[^) ]*\).*/\1/;"

hth.
Easy to suggest when don't know about the problem!
Sandman!
Honored Contributor

Re: Found a word

Iranzo,

Based on your reply here's the complete awk construct...

# awk '$0~/ 2\/6 /||$0~/^2\/6 /||$0~/ 2\/6$/{print substr($0,match($0,/ARASW/),7)}'

cheers!