Calling multiple commands with xargs
问题 cat a.txt | xargs -I % echo % In the example above, xargs takes echo % as the command argument. But in some cases, I need multiple commands to process the argument instead of one. For example: cat a.txt | xargs -I % {command1; command2; ... } But xargs doesn\'t accept this form. One solution I know is that I can define a function to wrap the commands, but it\'s not a pipeline, I don\'t prefer it. Is there another solution? 回答1: cat a.txt | xargs -d $'\n' sh -c 'for arg do command1 "$arg";