Hello there !
I have this script :
echo "<table>"
for fn in /var/www/cgi-bin/LPAR_MAP/*.csv;
do
echo "<td>"
echo "<PRE>"
awk -F',|;' '{ $0=$1","$2","$5","$6","$7} /'$test'/ { if (!a[$0]++)
{
print "DATE ================= : " FILENAME
printf "LPARS : %s\n", $2
printf "RAM : %s\n", $3
printf "CPU1 : %s\n", $4
printf "CPU2 : %s\n", $5
print ""
}
}' $fn
echo "</PRE>"
echo "</td>"
done
echo "</table"
That allow me to display some informations from many CSV files ( 276 CSV files… ) like that :
This script allow me to :
- delete duplicate lines with
if (!a[$0]++)
- Display the name of the file that the informations belongs
But, I would like to display only one filename and under it, all the informations from this file :
Date ======== 201908XX Date ======== 201908XX Date ======== 201908XX
LPARS : XX LPARS : XX LPARS : XX
RAM : XX RAM : XX RAM : XX
CPU 1 : XX CPU 1 : XX CPU 1 : XX
CPU 2 : XX CPU 2 : XX CPU 2 : XX
And I would like to change the ouput of the FILENAME variable :
DATE =================== /var/www/cgi-bin/LPAR_MAP/PowerSys-LPARmap-20180122.csv
To
DATE =================== 20180122
To keep only the date. I have this piece of script :
{ split(FILENAME,a,"[-.]");print "FILENAME ========================== : " a[4] }
But I have no idea to how integrate this piece of script in my awk script…
Do you have any idea ?
Thank you !