Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing a variable

Status
Not open for further replies.

frangac

Technical User
Feb 8, 2004
163
ZA
Hi All,

Below are 2 examples which I tried using, but does not seem to work. Any help.

B_num=034669762523

awk -v Num1=$B_num '{if($1~/Num1/){print $0}}'
or
awk -v Num1=$B_num '$1~Num1{print $0}'

Many Thanks
Chris
 
if on Solaris use nawk instead of awk:

awk -v Num1=$B_num '$1 ~ Num1 {print $0}' file

vlad
+----------------------------+
| #include<disclaimer.h> |
+----------------------------+
 
Chris:

Check out this awk faq:

faq271-1281

Regards,

Ed
 
Hi All,

Thanks for the replies.

I had a look at a previous post and saw that PHV stated that " awk '{if($2=="'$hostname_1'")print $1}', and this did the trick.

Thanks Once Again.
Chris
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top