[英]awk 'FNR == 2 {print}' issue
I have some task on which i need to know the install date of WLS which is located in second row of file called envVars.properties
which is located in /opt/weblogic1221/wlserver_12.2.1/installation/install/envVars.properties
.我有一些任务需要知道 WLS 的安装日期,它位于名为
envVars.properties
的文件的第二行,该文件位于/opt/weblogic1221/wlserver_12.2.1/installation/install/envVars.properties
中。 I have server which has multiple versions of WL there for I use *
in /opt/weblogic*/wlserver*/...
.我有服务器,那里有多个版本的 WL,因为我在
/opt/weblogic*/wlserver*/...
中使用*
。 But when I run cat /opt/weblogic*/wlserver*/installation/install/*.properties| awk 'FNR == 2 {print}'
但是当我运行
cat /opt/weblogic*/wlserver*/installation/install/*.properties| awk 'FNR == 2 {print}'
cat /opt/weblogic*/wlserver*/installation/install/*.properties| awk 'FNR == 2 {print}'
I get only 1 result (for the first file it finds). cat /opt/weblogic*/wlserver*/installation/install/*.properties| awk 'FNR == 2 {print}'
我只得到一个结果(对于它找到的第一个文件)。
See:看:
[root@server090 ~]# cat /opt/weblogic*/wlserver*/installation/install/*.properties| awk 'FNR==2{print}'
#Mon Feb 02 14:47:02 IST 2015
Without awk
:没有
awk
:
[root@server90 ~]# cat /opt/weblogic*/wlserver*/installation/install/*.properties
#Copyright (c) 1999, {0}, Oracle. All rights reserved.
#Mon Feb 02 14:47:02 IST 2015
JAVA_HOME_CCR=/usr/java/jdk1.7.0_72
#Copyright (c) 1999, 2016, Oracle. All rights reserved.
#Mon Feb 06 15:35:50 IST 2017
JAVA_HOME_CCR=/usr/java/jdk1.8.0_102
There are 2 files as you can see:如您所见,有2个文件:
[root@server90 ~]# ll /opt/weblogic*/wlserver*/installation/install/*.properties
-rwxr-xr-x. 1 oracle dba 121 Feb 2 2015 /opt/weblogic1213/wlserver_12.1.3/installation/install/envVars.properties
-rwxrwxrwx. 1 oracle dba 123 Oct 20 2017 /opt/weblogic1221/wlserver_12.2.1/installation/install/envVars.properties
Don't "cat through to awk", just specify the files after the awk
statement and so:不要“cat through to awk”,只需在
awk
语句之后指定文件,因此:
awk 'FNR == 2 {print}' /opt/weblogic*/wlserver*/installation/install/*.properties
Using cat
is needless and it will merge all input files into one single output, so awk
will just see one input file ( FNR
can only match once, then).使用
cat
是不必要的,它会将所有输入文件合并到一个 output 中,因此awk
只会看到一个输入文件( FNR
只能匹配一次)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.