Simpler Navigation coming for Servers and Operating Systems
Coming soon: a much simpler Servers and Operating Systems section of the Community. We will combine many of the older boards, and you won't have to click through so many levels to get at the information you need. If you are looking for an older board and do not find it, check the consolidated boards, as the posts are still there.
Operating System - Tru64 Unix
cancel
Showing results for 
Search instead for 
Did you mean: 

printf utility and find command

Razzz
Visitor

printf utility and find command

Hello All,

I am trying to generate a filelist and generate details of files like md5sum, size, date created, accessed, modified etc ... using the following command... but it throws the error printf not found ... any suggestions ?

find . -printf "%p\t%s\t%M\t%u\t%g\t%.24A+\t%.24T+\t%.24C+\t" -a \( -type d -exec echo \; -o -type f -exec sh -c "md5sum \"{}\" | cut -d' ' -f1" \; \)

6 REPLIES
Steven Schweda
Honored Contributor

Re: printf utility and find command

> I [...]

      uname -a
      sizer -v

> [...] but it throws the error printf not found [...]

   First, I'd trust copy+paste of an actual command with its actual
output more than your summary.  For example, I don't see how "find
-printf" could give that error, but...

   "find -printf" (or "printf" as a command) is a feature which is
likely too new for Tru64 (which is getting very old, and has not gotten
much development in recent years).  If you can't get what you want from
an "ls" command (or mutiple "ls" commands), then you might look into
building GNU "find" (or finding it already built for Tru64), and using
it instead of the built-in Tru64 "find".

      https://www.gnu.org/software/findutils/

Steven Schweda
Honored Contributor

Re: printf utility and find command

>       https://www.gnu.org/software/findutils/

   Seems to work for me (more or less):

urtx# /usr/local/bin/find --version
find (GNU findutils) 4.6.0
Copyright (C) 2015 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later
<http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by Eric B. Decker, James Youngman, and Kevin Dalley.
Features enabled: O_NOFOLLOW(enabled) LEAF_OPTIMISATION FTS(FTS_CWDFD) CBO(level=2)

urtx# /usr/local/bin/find -name 'siz*' -printf "%p\t%s\t%M\t%u\t%g\t%.24A+\t%.24T+\t%.24C+\t\n"
./siz.c 190     -rw-r--r--      root    system  %F+07:45:04.0000000000  %F+12:49:06.0000000000  %F+12:49:06.0000000000
./siz2.c        251     -rw-r--r--      root    system  %F+07:46:30.0000000000 %F+07:46:18.0000000000   %F+07:46:18.0000000000
./siz   20000   -rwxr-xr-x      root    system  %F+14:01:42.0000000000  %F+12:49:14.0000000000  %F+12:49:14.0000000000
./siz2  20000   -rwxr-xr-x      root    system  %F+17:14:44.0000000000  %F+07:46:31.0000000000  %F+07:46:31.0000000000


urtx# uname -a
OSF1 urtx.antinode.info V5.1 2650 alpha

urtx# sizer -v
HP Tru64 UNIX V5.1B (Rev. 2650); Wed Feb 17 22:59:59 CST 2016

urtx# gcc --version
gcc (GCC) 4.3.2
[...]

Razzz
Visitor

Re: printf utility and find command

Thanks Steven,

Let me try the same out and will inform you/all of the outcome.

Steven Schweda
Honored Contributor

Re: printf utility and find command

> Let me try the same out and will inform you/all of the outcome.

   GNU findutils is a start, but you may need to do more than I did if
you want to get that "%F" interpreted properly.  I haven't looked at the
"find" code (or builders), so I know nothing, but I'd guess that you'd
also need either a GNU "date" program or some piece of GNU run-time
library which is used to format those date-time values.  Apparently,
someone ("find") expects someone (else, unknown) to support a "%F"
format specification, but the Tru64 version of that function/program
doesn't recognize "%F" as anything special.

Razzz
Visitor

Re: printf utility and find command

The command was still showing some printf error related to predicate list ( I am thinking either I am not quoting properly or inserting some space somewhere ) ...

I installed the GNU find utils, GNU core utils, GCC , changed the path to reflect the GNU Utils, still erring on printf predicate list, so kicked the printf out of the way and used the ls command with ls -lu, ls -lc options and got the job done. I dont have a HP UX box to test the different commands unfortunately...

This command would work for sure ...

find . -printf "%p\t%s\t%M\t%u\t%g\t%AY-%Am-%Ad:%AH:%AM:%AS\t%TY-%Tm-%Td:%TH:%TM:%TS\t%CY-%Cm-%Cd:
%CH:%CM:%CS\t" -a \( -type d -exec echo \; -o -type f -exec sh -c "md5sum \"{}\" | cut -d' ' -f1" \; \)

regardless thanks a lot for your suggestions Steven ... :)

Steven Schweda
Honored Contributor

Re: printf utility and find command

>    GNU findutils is a start, but you may need to do more than I did if
> you want to get that "%F" interpreted properly.  I haven't looked at the
> "find" code (or builders), so I know nothing, but I'd guess that you'd
> also need either a GNU "date" program or some piece of GNU run-time
> library which is used to format those date-time values.  Apparently,
> someone ("find") expects someone (else, unknown) to support a "%F"
> format specification, but the Tru64 version of that function/program
> doesn't recognize "%F" as anything special.

   I looked at it a little, and decided that the likely culprit was
strftime().  The Tru64 strftime() is too old/lame to do "%F".
Interestingly, the findutils kit includes a strftime.c, but it seems to
be built with special options to provide an nstrftime() (and/or other
extra-feature varients), but not a plain GNU strftime().

   My quick evaluation is that this is a bug in GNU findutils (if they
want to support Tru64, that is).  The config.h says HAVE_STRFTIME, but
it's not clear that anyone cares, and the old/lame Tru64 strftime()
can't do what is expected of it by the GNU "find" code.

   What I enjoy most about GNU code is the way that any piece of GNU
code seems to drag in at least two other pieces of GNU code, and so on.