Re: Does find subdir -printf "%A\n" a bad example which is mentioned in the documentation?
On 20120328_191216, Regid Ichira wrote:
> $ zgrep -A3 '%A%p' /usr/share/info/find.info.gz
> newest=$(find subdir -newer timestamp -printf "%A%p\n" |
> sort -n |
> tail -1 |
> cut -d: -f2- )
>
> is taken from findutil's (4.4.2-4) documentation. It doesn't work
> here:
>
> $ mkdir -v subdir
> mkdir: created directory `subdir'
> $ touch subdir/file
> $ find subdir -printf "%A%p\n"
> %p
> %p
> $ find subdir -printf "%A\n"
> %\n%\n$
>
> I think the documentation's example assumes "%A\n" is supposed to
> print time information as is. While, in fact, there must be a
> modifier after the 'A'. Does
>
> find subdir -printf "%A\n"
>
> print time information for you? Am I right that the documentation's
> example assume it should work as is?
> Does the example also bad with respect to "%p"? If so, what is the
> correct formatting?
find subdir -printf "%Ap\n" prints AM or PM depending on the file's
access time in the local time zone of the computer. You string together
a bunch of %A each followed by a single letter from the list of letters
just below the %A under -printf in the man page to get a useful printing
of the file access time. i.e. there must be a 'k' and 'k' must be one
of the characters from that list ( including k can be @ even though @
is above the column heading of allowed k values ) I know this is confusing.
Try testing with
find subdir -printf "%A@ %Ap\n"
and see a somewhat useless but educational, I hope.
In place of the space in this trial, put a hyphen [-]
Try
find subdir -printf "%A@ %Ap %f\n"
to include the base name of the file without the path from subdir.
Look at
find subdir -printf "%i %b %M %n %U %G %s %TY%Tm%Td_%TH%TM%TS %p\n"
This is one I use and find convenient for some work. Figure out how it
works, and then write, and contribute a better man page. I would have
appreciated it when I was learning, but now that I know the truth I
can't see a better way to say it than is already there.
Enjoy ?-)
--
Paul E Condon
pecondon@mesanetworks.net
Reply to: