I’m trying to use xargs to evaluate a mathematical expression.

Like:

echo "1234" | xargs -I{} echo $(({}+1))

But, for whatever reason, {} is always evaluated as "0" (while I can confirm those are integer).

Any hint? Maybe something else than xargs for the job here?

Thanks everyone. The solution was to call sh -c with '$(())', the single quote is the important bit I was missing!

0

If you have a fediverse account, you can quote this note from your own instance. Search https://mamot.fr/users/ploum/statuses/115904082357006569 on your instance and quote it. (Note that quoting is not supported in Mastodon.)