For my CGI in bash/html, I have this script ( juste the awk script, the rest of the code is just a simple hmtl code ) :
for fn in /var/www/cgi-bin/LPAR_MAP/*; do
awk -F',|;' 'NR==1 { split(FILENAME ,a,"[-.]");
print "DATE ========================== : " a[4] }
/'$test'/ {
print ""
print "LPARS :" $2
print "RAM : " $5
print "CPU 1 : " $6
print "CPU 2 : " $7
print ""
print ""}' $fn;
done
My script analyze many CSV files and display the informations that I need like that :
DATE ========================== : 20180122
LPARS :miaibye01
RAM : 60
CPU 1 : 1.0
CPU 2 : 2
LPARS :miaibg04
RAM : 99
CPU 1 : 1.5
CPU 2 : 3
LPARS :miaibk07
RAM : 52
CPU 1 : 2.5
CPU 2 : 5
DATE ========================== : 20180124
LPARS :miaibye01
RAM : 60
CPU 1 : 1.0
CPU 2 : 2
LPARS :miaibg04
RAM : 99
CPU 1 : 1.5
CPU 2 : 3
LPARS :miaibk07
RAM : 52
CPU 1 : 2.5
CPU 2 : 5
LPARS :miaibv176
RAM : 0.25
CPU 1 : 0.1
CPU 2 : 1
...
But sometimes, When my script doesn't find the informations asked, it display the informations asked and juste the date of the file in which the script search the informations. The output is :
DATE ========================== : 20180923
DATE ========================== : 20180924
DATE ========================== : 20180925
DATE ========================== : 20180926
DATE ========================== : 20180927
DATE ========================== : 20180928
DATE ========================== : 20180929
DATE ========================== : 20180930
DATE ========================== : 20181001
I searched how to delete ( or not to show ) these useless line with my awk script, but I don't know how... Do you have any idea to do this ?