Let's suppose that you need to generate a NUL-delimited stream of timestamped filenames.
On Linux & Solaris I can do it with:
stat --printf '%.9Y %n\0' -- *
On BSD, I can get the same info, but delimited by newlines, with:
stat -f '%.9Fm %N' -- *
The man talks about a few escape sequences but the NUL byte doesn't seem supported:
If the
%is immediately followed by one ofn,t,%, or@, then anewlinecharacter, atabcharacter, apercentcharacter, or the current file number is printed.
Is there a way to work around that? edit: (accurately and efficiently?)
Update:
Sorry, the glob
*is misleading. The arguments can contain any path.I have a working solution that forks a
statcall for each path. I want to improve it because of the massive number of files to process.