System Administration
cancel
Showing results for 
Search instead for 
Did you mean: 

printf utility and find command

Razzz
Occasional 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" \; \)

4 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/

Highlighted
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
Occasional 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.