[Slackbuilds-users] find/chmod revisited

Arkadiusz Drabczyk arkadiusz at drabczyk.org
Fri Nov 13 21:23:51 UTC 2015


On 2015-11-12, Ricardo J. Barberis <ricardo at palmtx.com.ar> wrote:
> El Jueves 12/11/2015, B Watson escribió:
>> I've always known the template code that sanitizes the source permissions
>> is a bit slow... for mame, it takes a full minute to execute (using tmpfs
>> for TMP), since there are over 18 thousand files/dirs in the mame src.
>> (...)
>> That's a lot of child processes! So I thought "maybe I can use xargs
>> and cut the time down some". 
>> (...)
>
> And if xargs is not desired, find (at least on Slackware 14.1) 
> suports '-exec ... {} \+'.

One annoying feature of both xargs and find ... -exec \+ is that both
will try to run a specified command even if there are no arguments.
Example:

$ find . -name 'a' | xargs -0 chmod 644
chmod: missing operand after ‘644’
Try 'chmod --help' for more information.
$ find . -name 'a' -exec chmod 644 \+
find: missing argument to `-exec'

In case of GNU xargs it's easily fixed using -r and I think it should
be used here in an unlikely event of all files having correct
permissions:

--no-run-if-empty
-r  If the standard input does not contain any nonblanks, do not run
    the command.  Normally, the command is run once even if there is no
    input.  This option is a GNU extension.

That being said, on my machine with SanDisk SSD it took 20.363s to
process all files using current -exec method and 0.025s + 0.051s using
a new method so I think it's worth considering.

-- 
Arkadiusz Drabczyk <arkadiusz at drabczyk.org>



More information about the SlackBuilds-users mailing list