Skip to content
Advertisement

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. I have server which has multiple versions of WL there for I use * in /opt/weblogic*/wlserver*/.... But when I run cat /opt/weblogic*/wlserver*/installation/install/*.properties| awk 'FNR == 2 {print}' I get only 1 result (for the first file it finds).

See:

JavaScript

Without awk:

JavaScript

There are 2 files as you can see:

JavaScript

Advertisement

Answer

Don’t “cat through to awk”, just specify the files after the awk statement and so:

JavaScript

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).

Advertisement