Re: [PATCH] honor TIME_STYLE environment variable for formatting ls timestamp
Matt Panaro <[email protected]> Wed, 19 Nov 2025 23:18:35 -0500
| Newsgroups | gmane.comp.gnu.findutils.bugs |
|---|---|
| Message-ID | <[email protected]> |
Here's my proposed update to the documentation (I can send
again/additionally with `git send-email` if necessary; note also that
both the texi/info and the manpage file are patched):
diff --git a/doc/find.texi b/doc/find.texi
index 581807d7..34a1df9a 100644
--- a/doc/find.texi
+++ b/doc/find.texi
@@ -1842,6 +1842,16 @@ the treatment of unprintable characters is
harmonised for @samp{-ls},
@samp{-fls}, @samp{-print}, @samp{-fprint}, @samp{-printf} and
@samp{-fprintf}.
@end enumerate
+
+The implementation is currently hard-coded into the source code for
+@command{find}: it does not invoke or re-use code from the @command{ls}
utility.
+To obtain @command{ls} output with all the options available to it, use
+@samp{-exec} with @command{ls}:
+
+@example
+find . -type f -exec ls -ld --time-style='+%s' @{@} +
+@end example
+
@end deffn
@deffn Action -fls file
diff --git a/find/find.1 b/find/find.1
index a51a2f4b..43f7adb1 100644
--- a/find/find.1
+++ b/find/find.1
@@ -1431,6 +1431,16 @@ format on standard output.
The block counts are of 1\ KiB blocks, unless the environment variable
.B POSIXLY_CORRECT
is set, in which case 512-byte blocks are used.
+The implementation is currently hard-coded into the source code for
+.B find
+: it does not invoke or re-use code from the
+.B ls
+utility.
+To obtain
+.B ls
+output with all the options available to it, use e.g.
+.B `\-exec\ ls -dl --time-style='+%s' \&...`
+
See the
.B UNUSUAL FILENAMES
section for information about how unusual characters in filenames are
handled.
On 11/18/25 03:28, James Youngman wrote:
> On Tue, Nov 18, 2025 at 3:29 AM Matt Panaro <[email protected]> wrote:
>
> upon further reflection and experimentation, it seems like the easier
> solution to the referenced issue is the following (instead of a
> code patch):
>
> env TIME_STYLE='+%s' find ~/Documents -exec ls -ld \{\} \+
>
>
> Just in case TIME_STYLE ever affects find itself (in the future for
> example) this is more future-proof:
>
> find ~/Documents -exec env TIME_STYLE='+%s' ls -ld \{\} \+
>
> one could alternatively invoke the ls command's parameter:
>
> find ~/Documents -exec ls --time-style='+%s' -ld \{\} \+
>
>
> Indeed, and that doesn't have the risk I alluded to above.
>
> I do think it might be handy to have a parameter to coërce the -ls
> time
> output from find into something sortable, like
>
> find . -type f -ls -epoch
>
> without involving the user having to write any explicit formatting
> strings at all; but this probably isn't a common enough usecase to
> justify introducing an entirely new parameter to find. Maybe an
> update
> to the documentation for -ls, though? suggesting -exec ls if the
> full
> features of the ls command are necessary?
>
>
> If you think this is an important enough use-case to justify the
> consequent maintenance of that additional documentation, could you
> please suggest a patch to doc/find.texi to make the changes you have
> in mind?
>
> Thanks,
> James
>