the command

find /tmp -name 'core*' -type f -print0 | xargs -0

works fine on Linux, but xargs -0 option is not legal on Solaris

what is the equivalent option ( xargs? ) for Solaris 10

second question:
is it possible to change the syntax:

find /tmp -name 'core*' -type f -print0 | xargs -0

So it will fit for both OS - Linux and Solaris

I try on my solaris 10 machine:

find /tmp -name 'core*' -type f -print0 | xargs -0
xargs: illegal option -- 0
xargs: Usage: xargs: [-t] [-p] [-e[eofstr]] [-E eofstr] [-I replstr] [-i[replstr]] [-L #] [-l[#]] [-n # [-x]] [-s size] [cmd [args ...]]
  • see if your system has gxargs, possibly in /usr/sfw/bin, or /opt/sfw/bin. Then you can use the GNU specific options. – Tim Kennedy Mar 11 '13 at 13:40

Both the -print0 to find and the -0 to xargs are not POSIX, and may not be available everywhere. The + command terminator to -exec is part of POSIX, and will accomplish the same task. Here is an example.

find /tmp -type f -name 'core*' -exec rm {} +
  • ok but I cant think right solution and regarding my question , find /tmp -name 'core*' -type f -exec < which other syntax I can put here > in order to print the argument one after one , – yael Mar 7 '13 at 14:10
  • 3
    @yael that's what the + terminator does. – jordanm Mar 7 '13 at 15:15

The --print0 and -0 are GNU extensions. I believe the (almost) full suite of GNU tools is available for Solaris (perhaps under names like gfind, probably not installed by default).

Here is a list of suggested tools to install to make your Solaris experience more pleasant.


Use GNU Parallel in place of xargs:

find /tmp -name 'core*' -type f -print | parallel echo

It takes literally 10 seconds to install GNU Parallel:

wget pi.dk/3 -qO - | sh -x

Watch the intro videos to learn more: https://www.youtube.com/playlist?list=PL284C9FF2488BC6D1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.