HP-UX ***** B.11.23 U ia64 **** unlimited-user license
find . -type d -name *log* | xargs ls -la
gives me the directory names (the ones which contain log in the directory name) followed by all files within that directory.
The directories /var/opt/SID/application_a/log/, /var/opt/SID/application_b/log/, /var/opt/SID/application_c/log/ and so on contain log files.
I want only the two latest logfiles to be listed by the ls command, which I usually find using ls -latr | tail -2.
The output has to be something like this..
/var/opt/SID/application_a/log/
-rw-rw-rw- 1 user1 user1 59698 Jun 11 2013 log1
-rw-rw-rw- 1 user1 user1 59698 Jun 10 2013 log2
/var/opt/SID/application_b/log/
-rw-rw-rw- 1 user1 user1 59698 Jun 11 2013 log1
-rw-rw-rw- 1 user1 user1 59698 Jun 10 2013 log2
/var/opt/SID/application_c/log/
-rw-rw-rw- 1 user1 user1 59698 Jun 11 2013 log1
-rw-rw-rw- 1 user1 user1 59698 Jun 10 2013 log2
find . -type d -name *log* | xargs ls -la | tail -2 does not give me the above result. What I get is a list of last two files of
find . -type d -name *log* | xargs ls -la command.
So can I pipe commands after a piped xargs? How else do I query, to get the resultant list of files in the above format?
find . -type d -name *log* | xargs sh -c "ls -ltr | tail -10"
gives me a list of ten directory names inside the current directory which happens to be /var/opt/SID and that is also not what I want.