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

variable in awk....

Status
Not open for further replies.

nymus

IS-IT--Management
Jul 6, 2005
16
CH
Hi,

In a script I take the variable NF and print it:
Code:
BEGIN {FS=": "}
...
$1 ~ /first mount/ {print $NF}
...
result:
Tue Jul 23 14:26:37 DFT 2002

Now I want to put the last field of $NF (2002) in a variable:
Code:
$1 ~ /first mount/ {First="$NF|print $NF";print First}
But I don't see how? Has anyone an idea?
B.regards
nm
 
look at split function in your awk man page


HTH,

p5wizard
 
Try this:

Code:
d="Tue Jul 23 14:26:37 DFT 2002"
ans=array[split(d,array)]
print ans

is this what you want?
 
I've used split like so:
Code:
$1 ~ /first mount/ {split($NF,FMount," ")}
...
print "Fist Mount :"FMount[6]
it's work well....

Thanks a lot for your help :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top