Reputation: 233
I want to form an argument for tail using xargs.
"string" | xargs -I '{}' tail -F *{}*
This results in
tail "*{}*"
which does not work. How do I remove the quotes and turn it into a valid argument for tail
?
i.e. tail *string*
Upvotes: 1
Views: 378
Reputation: 6134
*
is interpreted by Bourne shell (pathname expansion) at the moment your command is parsed, before it is actually executed, NOT at the moment tail
is executed.
If you want that the command built by xargs
be subject to bash
's pathname expansion, you need to execute bash
:
echo "string" | xargs -I '{}' bash -c "tail -F *'{}'*"
Security issue: if you don't have control over the file names sent to xargs
, then with specially crafted filenames, you may end up inadvertently executing hamrful commands.
Upvotes: 1