From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <102653643321693.tru64-unix-managers.marc@archive.invalid> From: Tony Austin Date: Fri, 09 Nov 2001 16:14:13 +0000 To: tru64-unix-managers Subject: awk? X-MARC-Message: https://marc.info/?l=tru64-unix-managers&m=102653643321693 MIME-Version: 1 Content-Type: multipart/mixed; boundary="------_=_NextPart_001_01C16939.92C2B210" This message is in MIME format. Since your mail reader does not understand this format, some or all of this message may not be legible. ------_=_NextPart_001_01C16939.92C2B210 Content-Type: text/plain; charset="iso-8859-1" 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 ------_=_NextPart_001_01C16939.92C2B210 Content-Type: text/html; charset="iso-8859-1"
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
------_=_NextPart_001_01C16939.92C2B210--