我在没有成功的答案中搜索了......在RHEL Linux上,第一条命令列出了这条命令(我把那些我想要测试的东西放在这里。 ..):
ps -eaf | grep lsnr | grep -v ' LISTENER ' | grep -v grep
oracle 10258 1 0 2014 ? 01:34:43 /logicielPR1/oracle/product/11.2.0.4/bin/tnslsnr PRXPLO -inherit
oracle 10442 1 0 2014 ? 00:24:30 /logicielTE1/oracle/product/11.2.0.4/bin/tnslsnr TECHIMIO -inherit
oracle 10473 1 0 2014 ? 00:28:50 /logicielTE1/oracle/product/11.2.0.4/bin/tnslsnr TEIAC -inherit
oracle 10566 1 0 2014 ? 00:24:50 /logicielTE1/oracle/product/11.2.0.4/bin/tnslsnr TEIMG -inherit
oracle 14192 1 0 2014 ? 00:22:09 /logicielPR1/oracle/product/11.2.0.4/bin/tnslsnr PROCTM2 -inherit
oracle 27167 1 0 2014 ? 00:19:26 /logicielTE1/oracle/product/11.2.0.4/bin/tnslsnr TEOCTM -inherit
oracle 36854 1 0 2014 ? 00:19:59 /logicielTE1/oracle/product/11.2.0.4/bin/tnslsnr TEANA -inherit
oracle 37235 1 0 May20 ? 00:08:32 /logicielPR1/oracle/product/11.2.0.4/bin/tnslsnr PRCHIMIO -inherit
oracle 45141 1 0 Jun03 ? 00:08:02 /logicielST1/oracle/product/11.2.0.4/bin/tnslsnr PRIACS -inherit
oracle 48241 1 0 Sep25 ? 00:04:39 /logicielPR1/oracle/product/11.2.0.4/bin/tnslsnr PRINL -inherit
oracle 48708 1 0 Sep25 ? 00:03:27 /logicielTE1/oracle/product/11.2.0.4/bin/tnslsnr TEINL2 -inherit
我想提取上面的名称(如:第一行PRXPLO),所以我做的:
ps -eaf | grep lsnr | grep -v ' LISTENER ' | grep -v grep | awk -F "${ORA_LISTENER_HEADER}|${ORA_LISTENER_HEADER_UPPER}|tnslsnr " '{print $2}'
PRXPLO -inherit
TECHIMIO -inherit
TEIAC -inherit
TEIMG -inherit
PROCTM2 -inherit
TEOCTM -inherit
TEANA -inherit
PRCHIMIO -inherit
PRIACS -inherit
{print $2}
PRINL -inherit
TEINL2 -inherit
*注:在此命令,“$ {ORA_LISTENER_HEADER } | $ {ORA_LISTENER_HEADER_UPPER} | tnslsnr“将等于”tnslsnr“
显然,包含“{print $ 2}”的行不应该存在,但我找不到它的来源。 我知道我可以简单地通过grep排除它,但我更愿意理解我做错了什么。
有人可以帮我解决这个问题吗?
谢谢大家。
'PS -cargs = $(p纤ep TNSLSNR)| awk'$ 2!=“LISTENER”{print $ 2}''? – anishsane