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*
* 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.
"string" |result in abash: string: command not founderror? Do you have a command namedstring?This results inHow do you know? How did you check that it results in that?How do I remove the quotesWho added the qoutes? How were they added?turn it into a valid argument for tail?Is"*{}*"and invalid argument? Do you really have a filename named literally*string*that you want tail from? Or do you expect*string*to expand to list of filenames that match the globulation pattern?which does not workIs there an error message?*symbols in your comment have been interpreted as markup - please can you check the formatting (e.g. putting the code inside backticks).echo "string" | xargs -I '{}' tail -F {}