Can anyone provide Solaris equal command to the following command

$ find . -type f -printf '%f,%h\n'

After running the code I am getting "bad option printf find: [-H | -L] path-list predicate list error "

Printf is not supported by Solaris UNIX environment

Please refer to following links for more information:



Thanks in advance

  • 1
    Try man find.
    – John
    Commented Aug 30, 2016 at 19:04
  • I am new to UNIX and can you help me out on how to use man find. I cannot install any other software too Commented Aug 30, 2016 at 19:08
  • 2
    Which version of Solaris? You may have a gfind command. Commented Aug 30, 2016 at 19:09
  • Type the command man find. If you have man pages installed, it will let you read how to use the find command.
    – John
    Commented Aug 30, 2016 at 19:11
  • Did you try the alternative solution posted in answer to your earlier question How to create a new file which provides filename and its source directory information? Commented Aug 30, 2016 at 19:14

1 Answer 1


The -printf action is specific to GNU find, so it isn't available on platforms that don't run GNU find. Only non-embedded Linux and Cygwin run GNU find unless you've installed it separately.

You can install GNU find on Solaris.

Alternatively, you can rewrite your script to use only portable features. There is no generic way to translate -printf: different specifiers will need different tools. For %f and %h, it's easy, since these are just parts of the file name. If the file name is in a shell variable x, you can use parameter expansion constructs to extract the base name (remove the prefix */) and the directory name (remove the suffix /*).

find . -type f -exec sh -c 'for x do printf %s,%s\\n "${x##*/}" "${x%/*}"; done' sh {} +
  • Hi Thanks for the solution. But i am getting ; unexpected error while running the code Commented Aug 31, 2016 at 6:06
  • @vinodkumar Oh right, remove the ; before do, that's a common but non-standard syntax. Commented Aug 31, 2016 at 7:46
  • Now getting find:incomplete statement error Commented Sep 1, 2016 at 23:39
  • @vinodkumar Did you copy the command exactly? Are you using some extremely ancient version of Solaris that doesn't support -exec … {} +? Are you calling /usr/bin/find or /usr/xpg4/bin/find? Commented Sep 2, 2016 at 7:07

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .