How can I use xargs to run a function in a command substitution for each match?
问题 While writing Bash functions for string replacements I have encountered a strange behaviour when using xargs. This is actually driving me mad currently as I cannot get it to work. Fortunately I have been able to nail it down to the following simple example: Define a simple function which doubles every character of the given parameter: function subs { echo $1 | sed -E "s/(.)/\1\1/g"; } Call the function: echo $(subs "ABC") As expected the output is: AABBCC Now call the function using xargs: