bug-findutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

-ls0


From: Karl Berry
Subject: -ls0
Date: Thu, 29 Dec 2011 16:35:37 -0800

James or anyone,

I've been in the habit of using find -ls to record all files in a given
hierarchy.  Of course, parsing the output of that becomes problematic
when a file name contains a newline or other special characters.  So
what I really want is -ls0, where the entries are delimited with nulls
instead of newlines.

In the case of symlinks, I think the " -> " suffices to separate the
symlink name from the target name.  That is, I'm willing to accept the
lossage if a filename contains that string.  Less likely than a newline,
anyway, and anything involving nulls would greatly complicate the
parsing of the output.  Oh, maybe it should be \n->\n, that would be
even less probable.

I thought I would be able to use -printf to get the equivalent, but this
appears to be impossible.  Aside from formatting trivialities, I don't
see a directive or option or other setting to print the exact filename
the way that -print0 does.  Am I missing something obvious?  Is there a
way for -printf to print the raw file name?  Or the escaped (as in -ls)
filename, for that matter?

Also, I don't see a way to get the " -> " in symlink entries (without
running a separate find for symlinks only), but I guess it's ok for my
purposes to just unconditionally use %l.

The closest I could get was this:
  find -printf "%i %k %M %n %u %g %s %T+ %p\n->\n%l\0"

BTW, if/when there is an equivalent way to do it using -printf, I think
it would be good to state it in the manual (Node: Print File
Information), as well as mentioning `ls -dils'.

Thanks,
Karl



reply via email to

[Prev in Thread] Current Thread [Next in Thread]