English 中文(简体)
• 如何从AIX、SunOS、Libert和HP-UX的倾斜输出中提取版本
原标题:How to extract version from tnsping output in AIX, SunOS, Linux and HP-UX

我想从AIX的拖 output产出中抽取10.2.0.,因此,我写了<条码>:tnsping tucson , grep 》>a wk{印有9},但有时在其他平台上,如其他平台,例如: 栏目各不相同,因此我无法在任何地方使用<代码>{印有9}。 有这样的办法:

  1. The command looks for Version
  2. and then just after it prints whatever number comes up (including ".")

还是任何其他方法?

TNS Ping Utility for IBM/AIX RISC System/6000: Version 10.2.0.4.0 - Production on 16-NOV-2011 16:19:02

Copyright (c) 1997,  2007, Oracle.  All rights reserved.

Used parameter files:

Used HOSTNAME adapter to resolve the alias
Attempting to contact (DESCRIPTION=(CONNECT_DATA=(SERVICE_NAME=bluebird.informatica.com))(ADDRESS=(PROTOCOL=TCP)(HOST=10.65.40.235)(PORT=1521)))
TNS-12535: TNS:operation timed out

下面请参阅AIX、HPUX和LC:

tnsping tucson | grep Version | awk -F Version   {print $2}  | awk  {print $1} 

但我在<>SunOS上发现了一个错误。 我想要的是那些将针对六氯环己烷、六氯环己烷-未爆弹药、AIX和SunOS的工作。

zenvo%  tnsping tucson | grep Version | awk -F Version   {print $2}  | awk  {print $1} 
awk: syntax error near line 1
awk: bailing out near line 1

Update after Shelter s answer

林丹

tnsping tucson | grep Version | awk -F Version   {print $2}  | awk  {print $1} 

SunOS:

tnsping tucson | grep Version | nawk -F Version   {print $2}  | nawk  {print $1} 
最佳回答

AWK on Solaris是老的AWK。 通常,太阳能人利用Nawk获得新的AWK的好处。

我不认为老的AWK支持一种多功能价值,即你界定的“条码”——F版

更可能的话,你必须用手法在太阳系上分配 n。

类似于

case $( uname -a ) in
    *Solaris* ) awk=nawk ;;
    * ) awk=awk
esac

tnsping tucson | grep Version | ${awk} -F "Version"   {print $2}  | ${awk}  {print $1} 

我们应该 do。 我再也没有机会使用太阳系,因此我无法核实这一系统将发挥作用,但我感到惊讶。

Hmm, 我现在从我过去的故事告诉我,甚至太阳系的Nawk, 就像地毯一样。 或许,如果你能够找到一个安装了精彩的陶器,另一种解决办法(似乎你会重新回到那里的道路),那么就更不用说。

tnsping tucson | ${awk}  /Version/ {sub(/,*Version /, "", $0) ; sub(/.*$/, "", $0); print $0; exit} 

并且,你应该直截了脚。 另外,随着AWK的过滤器,在AWK的过滤器中,你不需要在中间的消融,我们取消了对AWK的额外呼吁。

我希望这一帮助。

问题回答




相关问题
Signed executables under Linux

For security reasons, it is desirable to check the integrity of code before execution, avoiding tampered software by an attacker. So, my question is How to sign executable code and run only trusted ...

encoding of file shell script

How can I check the file encoding in a shell script? I need to know if a file is encoded in utf-8 or iso-8859-1. Thanks

How to write a Remote DataModule to run on a linux server?

i would like to know if there are any solution to do this. Does anyone? The big picture: I want to access data over the web, using my delphi thin clients. But i´would like to keep my server/service ...

How can I use exit codes to run shell scripts sequentially?

Since cruise control is full of bugs that have wasted my entire week, I have decided the existing shell scripts I have are simpler and thus better. Here is what I have so far svn update /var/www/...

Good, free, easy-to-use C graphics libraries? [closed]

I was wondering if there were any good free graphics libraries for C that are easy to use? It s for plotting 2d and 3d graphs and then saving to a file. It s on a Linux system and there s no gnuplot ...

热门标签