Sudar
Sudar

Reputation: 20000

xargs and argument position

I have a directory with a couple of PHP files in multiple levels. I want to execute the following command for all of these PHP files.

php ../../i18n/add-textdomain.php -i bulk-delete file_name.php

So, I wrote the following find command and piped it to xargs

find . -iname "*.php" -type f -print0| xargs -0 php ../../i18n/add-textdomain.php -i bulk-delete

The php command expects the PHP file to be the last argument. I assumed xargs will append the files listed by find at the end. But this doesn't seem to be happening.

How to tell xargs to add the arguments at the end of the command?

Upvotes: 1

Views: 3847

Answers (1)

Michael Burr
Michael Burr

Reputation: 340316

xargs does append the items in stdin to the end of the command by default. You can use -I to override that, but it seems that something else is going wrong for you. Do you need only one PHP file per command? If so, use -n 1.

Upvotes: 6

Related Questions