Re: grep command (150 Views)
Reply
Honored Contributor
RAC_1
Posts: 5,920
Registered: ‎03-21-2002
Message 26 of 28 (150 Views)

Re: grep command

I think this is not possible with grep/egrep/fgrep. May be gnu grep will help.

Without gnu grep, you can do it as follows.

grep "156.152.45.5" ./file|awk -F " " '{if(length($1)==12)print}'

Anil
There is no substitute to HARDWORK
Please use plain text.
Honored Contributor
curt larson_1
Posts: 764
Registered: ‎08-23-2002
Message 27 of 28 (150 Views)

Re: grep command

similar to Mr. Soler's

awk -v var=$ADRESSIP '
$1 == var {print $2;}' yourFile
Please use plain text.
Honored Contributor
Muthukumar_5
Posts: 4,030
Registered: ‎06-09-2004
Message 28 of 28 (150 Views)

Re: grep command

Hai,

We can use ^ and $ to notify the begin and end of string. It is easy to get the exact string.

ADRESSIP=156.152.45.5
grep ^${ADRESSIP}$

Regards,
Muthukumar
Easy to suggest when don't know about the problem!
Please use plain text.
The opinions expressed above are the personal opinions of the authors, not of HP. By using this site, you accept the Terms of Use and Rules of Participation