Question

For example, if I have a command:

find . -name "*.png" |xargs -I{} sh -c "mycommand {}"

If I have a.png and b.png in the current folder, I want a way to show the following, but not execute them:

mycommand a.png
mycommand b.png

Is there anyway to achieve this?

Was it helpful?

Solution

You could change that command to

find . -name "*.png" |xargs -I{} echo "mycommand {}"

If you just want to show the command before execute it, you could use -t option of xargs:

find . -name "*.png" |xargs -t -I{} sh -c "mycommand {}"
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top