hint: any OS commands are accessible from within awk with "system" call. vlad
+---------------------------+
|#include<disclaimer.h> |
+---------------------------+
function dirlist(dir,pat, array1,x) {
if (!pat || !dir) {
perror("No pattern or directory for file matching.", 1)
}
command = "ls -l " dir pat " | sort"
while ((command |& getline) > 0) {
array1[$9] = $5 / 1024
}
parray(array1,x)
tlist = array_to_list(array1)
return tlist
}
function array_to_list(arrname, tlist,m) {
for (m in arrname) {
tlist = length(tlist) < 1 ? arrname[m] : tlist" "arrname[m]
}
return tlist
}
function perror(msg,flg) {
printf "%s\n", msg
if (flg) {
exit
}
return
}
function parray(arrname,len, x) {
while (x <= len) {
print arrname[x++]
}
return
}
BEGIN {
x = 0;
xlist = dirlist("/home/me/","*.txt"
if (xlist) {
split(xlist,arr)
for (x in arr) {
print x , arr[x]
}
}
}
{
more stuff
}
thanks vlad, that answers part of my question
could be so kind to take a look at this:
I am parsing a log file
Oct 2 05:50:07 /mniprod/xmit/o.coneg.1002020346
Oct 2 05:50:15 /mniprod/xmit/o.coneg.1002020347
Oct 2 05:50:27 /mniprod/xmit/o.coneg.1002020356
Oct 2 05:51:08 /tsiprod/xmit/o.tetra.1002020422
I need to get the file size of the file in the log.
END {
for (i in filesARR)
printf("%s -> [%s]\n", i, filesARR);
}
vlad
+---------------------------+
|#include<disclaimer.h> |
+---------------------------+
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.