I would like to create a .txt file for each filesystem ( so hd1.txt, hd2.txt, hd3.txt and hd4.txt ) and put in each .txt file the sum of the value from each FS from each dataX.txt. I've some difficulties to explain in english what I want, so here an example of the result wanted
"But it doesn't works..." is not something people can start working / analysing / debugging upon. Be more precise / descriptive; include error messages, warnings, non-satisfying output, etc.
I've try many different things in bash and my last script that most closely resembled at what I want take much more time ( 3minutes ) to do what your script do instantly. So thanks for that !
Last things, if I want to specify the path where are my data, I've just to do that ? :
' OFS=\; SUBSEP=\; /my/full/path/*.txt
And, If I understand how to change for the loclisation of my data, at this step :
END {for (s in SUM) {n = split (s, T, "[;/]") print s, SUM, MNT > (T[n] ".txt") } }
How can I specify the path where I want to put the result of the script ?
1) Yes
2) How do you want to convey the target path to the script? In case you want to use the source files' path, and this is constant, to place the hd*.txt files next to the sources, try (in the END section)
END {PTH = FILENAME
sub (/[^\/]*$/, "", PTH)
for (s in SUM) {n = split (s, T, "[;/]")
print s, SUM, MNT " > " (PTH T[n] ".txt")
}
}
assuming the FILENAME variable is still defined and valid in that section.
Else you can use awk 's -v mechanism to supply the path.