| Poster 2000 2002-12-19, 6:25 am |
|
First posted NNTP-Posting-Date: Sun, 08 Dec 2002 13:01:36 +0000
to comp.unix.shell
As there has been no reply to this in over a week, I can only
conclude.
1) My News sever has lost the post and not transmitted it outwards.
2) Nobody has read the post.
3) Nobody wants to answer the post.
4) None of the above
Whatever, second and final attempt. Followups set to
comp.unix.shell. Adjust as required
bash --version
GNU bash, version 2.04.11(1)-release (i386-redhat-linux-gnu)
Copyright 1999 Free Software Foundation, Inc.
What I am trying to do is, start from base directory, recurse down 2
levels, for each directory 2 levels down sort the named files so as to extract the
highest numbered file , eg file1 file2 etc for each
of the highest numbered files, extract an update tag embedded in the
file, print out the update tag time the directory it was in and the
file name.
What I have does the first 2 though anything better is appreciated,
but I can't get the name.
find -maxdepth 2 -mindepth 2 | while read directory; do ls -v "$directory" | tail -1 | xargs -iname grep updated "${directory}/name" | awk -F: '{print $NF, name}' name=$directory; done
I can get the list of directories with find, I can sort them with ls
-v and extract the last with tail -1. I have never been able to get {}
with xargs to work properly, should I quote not quote etc, I have been
able to get irepacement working though. The problem is name set in
xargs is I think internam to xargs and not a shell variable, so I can
not pass it to awk later on. Also as far as I can see I can only run
1 command with xargs, so I can't do xargs -iname name=name; grep
updated etc
I have also tried tail -1 | xargs -iname name=name | xargs -iname grep
etc.
but this fails since name is not a command so gives the error message
no such file or directory. So how would I pass the name extracted by
xargs from the tail -1 output so as to be able to use this later?
--
From Poster 2000 <p_oster_2000@yahoo.com.invalid>
To reply use Reply-To or remove Invalid
|