[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: -ls0
From: |
Karl Berry |
Subject: |
Re: -ls0 |
Date: |
Sat, 31 Dec 2011 11:35:56 -0800 |
Hi James,
Thanks for the quick reply.
Why not just use \0 in the format specification?
Of course. That was the basic idea of what I was trying.
Alternatively, emit the symlinks into a separate file with -fprintf.
Yes, a viable and more reliable alternative. Only downside is that it's
a bit more annoying to have two files hanging around.
Unprintable/unusual characters are escaped only when the output is
going to a tty. See the info node "Unusual Characters in File Names"
I saw that, but ... well, doesn't matter now. Yes, ok, works.
So, how about giving this as an example in the manual? Something like
(under -printf):
--- f/ORIG/find.texi 2011-12-29 11:23:41.000000000 -0800
+++ f/find.texi 2011-12-31 11:15:18.000000000 -0800
@@ -1683,2 +1683,21 @@
you want a newline at the end of the string, add a @samp{\n}.
+
+As an example, an approximate equivalent of @samp{-ls} with
+null-terminated filenames can be achieved with this @code{-printf}
+format:
+
address@hidden
+find -printf "%i %4k %M %3n %-8u %-8g %8s %T+ %p\n->%l\0" | cat
address@hidden example
+
+A practical reason for doing this would be to get literal filenames in
+the output, instead of @samp{-ls}'s backslash-escaped names. (This is
+also why we pipe through @code{cat}; @pxref{Unusual Characters in File
+Names}). This format also outputs a uniform timestamp format.
+
+As for symlinks, the format above outputs the symlink target on a
+second line, following @samp{\n->}. There is nothing following the
+arrow for non-symlinks. Another approach, for complete consistency,
+would be to @code{-fprintf} the symlinks into a separate file, so they too
+can be null-terminated.
@end deffn
Diff finished at Sat Dec 31 11:19:37
- -ls0, Karl Berry, 2011/12/29