From: Tony Austin <taustin () solucient ! com>
To: tru64-unix-managers
Subject: awk?
Date: Fri, 09 Nov 2001 16:14:13 +0000 [thread overview]
Message-ID: <102653643321693.tru64-unix-managers.marc@archive.invalid> (raw)
[-- 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 and assign it to a variable for evaulation. For instance,
for sever A</FONT></SPAN></DIV>
<DIV><SPAN class=121300516-09112001><FONT size=2></FONT></SPAN> </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> </DIV>
<DIV><SPAN class=121300516-09112001><FONT size=2>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:</FONT></SPAN></DIV>
<DIV><SPAN class=121300516-09112001><FONT size=2>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.</FONT></SPAN></DIV>
<DIV><SPAN class=121300516-09112001><FONT size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=121300516-09112001><FONT size=2>Any assistance greatly
appreciated. Regards, </FONT></SPAN><SPAN class=121300516-09112001><FONT
size=2>Tony</FONT></SPAN></DIV>
<DIV><FONT size=2></FONT> </DIV>
<DIV><FONT size=2></FONT> </DIV>
<DIV><SPAN class=121300516-09112001><FONT size=2>Code Start</FONT></SPAN></DIV>
<DIV><SPAN class=121300516-09112001><FONT size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=121300516-09112001><FONT
size=2>#!/usr/bin/ksh</FONT></SPAN></DIV>
<DIV><FONT size=2></FONT> </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> </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> </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><FONT size=2></FONT> </DIV>
<DIV><SPAN class=121300516-09112001><FONT size=2>awk: Field $() is not
correct.</FONT></SPAN></DIV>
<DIV><FONT size=2></FONT> </DIV>
<DIV><SPAN class=121300516-09112001><FONT size=2> The input line number is
1.<BR> The source line number is 1.</FONT></SPAN></DIV>
<DIV><SPAN class=121300516-09112001><FONT size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=121300516-09112001><FONT size=2>Output
End</FONT></SPAN></DIV></BODY></HTML>
------_=_NextPart_001_01C16939.92C2B210--
reply other threads:[~2001-11-09 16:14 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
read-only archive
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox