On 11/14/05, Carl Lowenstein <[EMAIL PROTECTED]> wrote:
> On 11/13/05, Scott McClelland <[EMAIL PROTECTED]> wrote:
> > Here is the idea with a more complete list of songs.
> > $ ls -lRh
> > .:
> > total 0
> > dr-xr-xr-x+ 2 Administ None 0 Feb 28 2005 1969 Yes
> > dr-xr-xr-x+ 2 Administ None 0 Feb 28 2005 1970 Time And A Word
> > dr-xr-xr-x+ 2 Administ None 0 Feb 28 2005 1971 The Yes Album
> > dr-xr-xr-x+ 2 Administ None 0 Feb 28 2005 1972 Close To The
> > Edge
> . . . many lines snipped . . .
>
> I see what you have here. It is a listing that has been nicely
> arranged for people to look at, but is not very nice for a computer
> program to parse. I do have a program that could be used to put this
> back into a better form, but you can do the same thing with the
> original files. The command line that will produce a listing that
> shows the relevant information without pretty-printing is the
> following:
>
> $ tar cf - . | tar tvf - | gawk '{$1=$2=$5=""; print}' > /tmp/file.lst
>
> Explanation:
> The first "tar" command creates an annotated image file of everything
> in the directory and subdirectories.
> The second "tar" command reads the annotation from the image file.
> The "gawk" command keeps the relevant information, namely file size,
> date, and directory path and file name, discarding file attributes,
> owner, and time-of-day.
There's gotta be a better way! This takes an hour and a half to go
through 120GB of files.
With GNU find (present on Linux systems) the better way is:
$ find . -type f -printf "%s %TY-%Tm-%Td %p\n"
This takes about 2.5 seconds. :-)
Explanation, as usual.
find . -type f # find, starting at this
directory, files (not directories)
-printf "%s # print file size, bytes
%TY-%Tm-%Td # file modification time, yyyy-mm-dd
%p%b" # file name, newline
Only advantage of the "tar piped to tar" is that it works in the
absence of GNU utilities, and I thought of it first.
carl
--
carl lowenstein marine physical lab u.c. san diego
[EMAIL PROTECTED]
--
[email protected]
http://www.kernel-panic.org/cgi-bin/mailman/listinfo/kplug-newbie