Confirming operations with `xargs -p`
xargs
is a great tool to take a lot of input and execute a lot of different commands based on that input. Sometimes though, if you are performing destructive or mutative actions with xargs you want to proceed more cautiosly.
> echo "banana apple orange" | tr ' ' '\n' | xargs -n1 echo "I like"
This outputs:
I like banana
I like apple
I like orange
But maybe I don't like some of those things, please ask! Including the p
flag with xargs forces a prompt.
> echo "banana apple orange" | tr ' ' '\n' | xargs -p -n1 echo "I like"
echo I like banana ?...n
echo I like apple ?...y
I like apple
echo I like orange ?...n
Yep, I only like apples.
Tweet