HI all
I have multiple csv files with the names
VAR1\_VAR2\_VAR3_VAR4.csv
All the files have the same structure inside just values change.
I am trying to retrieve data from those files by fixing at each time one or more VAR.
I tried to write a script but I have 2 problems:
2- When I fix one variable (i.e, *_VAR2_VAR3_VAR4.csv ) on when VAR1 have 3 entries how to iterate this variable inside a loop ?
My script is here (My first tentative)
#!/bin/bash
#OLDFIS=$IFS
#IFS=","
awk -F "," '
#-------------------------- Table 1 ----------------------- -------#
# Header begin
BEGIN {
print"=========================================================="
printf"%-8s %-8s %-8s %-8s %-8s\n","Network size", "P_Energy", "E_Energy",
"All_energy","Latency"
print"=========================================================="
}
# Header end
NR==3 {printf "%-20s", $1 } NR==25 {printf "%-20s", $2 } NR==12 {printf "%-20s", $2 }
NR==29 {printf "%-20s", $2 } NR==49 {printf "%-20s", $4 }' /...PATH/ *.csv >test.txt
#-----------------------------------------------------------------------------#
Output:
========================================================================
Network size P_Energy E_Energy All_energy Latency
=========================================================================
0.0402597 0.00767312 0.0479328 0.294311
With this code I have two problems:
1- Even I specify a large number of files I get only one row, should I add a loop?
2-I want to parse a set of files by fixing one variable (VAR1), and use its different value as the first column of my output.
Any ideas please?