awk?

From: Tony Austin <taustin_at_solucient.com>
Date: Fri, 09 Nov 2001 08:14:13 -0800

I need to get the current os version and assign it to a variable for
evaulation. For instance, for sever A
 
Digital UNIX V4.0F (Rev. 1229); Wed Dec 6 10:49:24 PST 2000
 
I would want to get just teh 4.0F portion. I thought that I could use awk
to get the position of the version number and then just issue a cut -c... to
get the data. However , I am having trouble getting the awk portion to work
properly. When running the script is just sits these until I hit enter and
then it returns and error. I was going to do this:
z=`/usr/sbin/sizer -v|awk '{print $3}'|cut -c 2-4` but depending of the
version you get different output and the character positions aren't the same
therefore I get incorrect results.
 
Any assistance greatly appreciated. Regards, Tony
 
 
Code Start
 
#!/usr/bin/ksh
 
y=`/usr/sbin/sizer -v`
echo $y
z=`awk '{index ($y,"V")}'`
echo $z
 
Code End
-----------------------------------
Output Start
 
$>Digital UNIX V4.0F (Rev. 1229); Wed Dec 6 10:49:24 PST 2000
 
awk: Field $() is not correct.
 
 The input line number is 1.
 The source line number is 1.
 
Output End
Received on Fri Nov 09 2001 - 16:15:24 NZDT

This archive was generated by hypermail 2.4.0 : Wed Nov 08 2023 - 11:53:42 NZDT