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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Variable assignment doing weird things!!

Status
Not open for further replies.

burnettben

Programmer
Apr 24, 2005
7
0
0
AU
I am trying to assign a variable the value of a field.

I tried to use:

awk 'BEGIN{name="";} { print $3;
name=$3;
print $name; }' file

but what it outputs is the correct field for first print ($3) but then when i assign and then print it assigns the whole line, i am really confused!!!

Anyone got any suggestions!!

Ben
 
change
print $name

TO

print name

[BTW, awk != perl]

vlad
+----------------------------+
| #include<disclaimer.h> |
+----------------------------+
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top