How can I get a formatted directory listing using awk?
Posted on 2003-11-26
I want to get a formatted directory listing that I can parse using other utilities such as perl, Excel, etc. The unix "ls" command does not provide an easy way to accomplish this. I am collecting the listings from servers running Linux, Solaris, HP-UX, or AIX. All four OS's have some form of awk on it.
I would prefer the listing to be delimited and contain the full path names... i.e.
-rwxr-xr-x|root|system|125713|Sep 14 12:23|/usr/local/bin/sshd2
-rwxr-xr-x|root|system|125021|Sep 14 12:23|/usr/local/bin/scp2
Can this be done and how? A working example would be great! I could do this in perl, but I am not guaranteed that perl is available on all of the systems. Also, if you can suggest another way of doing this for all 4 OS's if it is not possible with awk, that would be cool too!