tru64-unix-managers (formerly alpha-osf-managers) (1994-2012)
 help / color / mirror / Atom feed
* awk?
@ 2001-11-09 16:14 Tony Austin
  0 siblings, 0 replies; only message in thread
From: Tony Austin @ 2001-11-09 16:14 UTC (permalink / raw)
  To: tru64-unix-managers

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: multipart/mixed; boundary="------_=_NextPart_001_01C16939.92C2B210", Size: 4668 bytes --]

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"

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">


<META content="MSHTML 5.50.4807.2300" name=GENERATOR></HEAD>
<BODY>
<DIV><SPAN class=121300516-09112001><FONT size=2>I need to get the current os 
version&nbsp; and assign it to a variable for evaulation.&nbsp; For instance, 
for sever A</FONT></SPAN></DIV>
<DIV><SPAN class=121300516-09112001><FONT size=2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=121300516-09112001><FONT size=2>Digital UNIX V4.0F (Rev. 1229); 
Wed Dec 6 10:49:24 PST 2000 </FONT></SPAN></DIV>
<DIV><SPAN class=121300516-09112001><FONT size=2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=121300516-09112001><FONT size=2>I would want to get just teh 
4.0F portion.&nbsp; 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.&nbsp; However , 
I am having trouble getting the awk portion to work properly.&nbsp; When running 
the script is just sits these until I hit enter and then it returns and 
error.&nbsp; I was going to do this:</FONT></SPAN></DIV>
<DIV><SPAN class=121300516-09112001><FONT size=2>z=`/usr/sbin/sizer -v|awk 
'{print $3}'|cut -c 2-4`&nbsp; but depending of the version you get different 
output and the character positions aren't the same therefore I get incorrect 
results.</FONT></SPAN></DIV>
<DIV><SPAN class=121300516-09112001><FONT size=2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=121300516-09112001><FONT size=2>Any assistance greatly 
appreciated.&nbsp; Regards, </FONT></SPAN><SPAN class=121300516-09112001><FONT 
size=2>Tony</FONT></SPAN></DIV>
<DIV><FONT size=2></FONT>&nbsp;</DIV>
<DIV><FONT size=2></FONT>&nbsp;</DIV>
<DIV><SPAN class=121300516-09112001><FONT size=2>Code Start</FONT></SPAN></DIV>
<DIV><SPAN class=121300516-09112001><FONT size=2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=121300516-09112001><FONT 
size=2>#!/usr/bin/ksh</FONT></SPAN></DIV>
<DIV><FONT size=2></FONT>&nbsp;</DIV>
<DIV><SPAN class=121300516-09112001><FONT size=2>y=`/usr/sbin/sizer -v`<BR>echo 
$y<BR>z=`awk '{index ($y,"V")}'`<BR>echo $z</FONT></SPAN></DIV>
<DIV><SPAN class=121300516-09112001><FONT size=2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=121300516-09112001><FONT size=2>Code End</FONT></SPAN></DIV>
<DIV><SPAN class=121300516-09112001><FONT 
size=2>-----------------------------------</FONT></SPAN></DIV>
<DIV><SPAN class=121300516-09112001><FONT size=2>Output 
Start</FONT></SPAN></DIV>
<DIV><SPAN class=121300516-09112001><FONT size=2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=121300516-09112001><FONT size=2>$&gt;Digital UNIX V4.0F (Rev. 
1229); Wed Dec 6 10:49:24 PST 2000</FONT></SPAN></DIV>
<DIV><FONT size=2></FONT>&nbsp;</DIV>
<DIV><SPAN class=121300516-09112001><FONT size=2>awk: Field $() is not 
correct.</FONT></SPAN></DIV>
<DIV><FONT size=2></FONT>&nbsp;</DIV>
<DIV><SPAN class=121300516-09112001><FONT size=2>&nbsp;The input line number is 
1.<BR>&nbsp;The source line number is 1.</FONT></SPAN></DIV>
<DIV><SPAN class=121300516-09112001><FONT size=2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=121300516-09112001><FONT size=2>Output 
End</FONT></SPAN></DIV></BODY></HTML>

------_=_NextPart_001_01C16939.92C2B210--

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2001-11-09 16:14 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2001-11-09 16:14 awk? Tony Austin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox