I’m trying to run the following command:
find . -iname '.#*' -print0 | xargs -0 -L 1 foobar
where ‘foobar’ is an alias or function defined in my .bashrc file (in my case, it’s a function that takes one parameter). Apparently xargs doesn’t recognize these as things it can run. Is there a clever way to remedy this?
Since only your interactive shell knows about aliases, why not just run the alias without forking out through
xargs?If you’re sure that your filenames don’t have newlines in them (ick, why would they?), you can simplify this to
or even just
find -iname '.#*' | ..., since the default directory is.and the default action is-print.One more alternative:
telling Bash that words are only split on newlines (default:
IFS=$' \t\n'). You should be careful with this, though; some scripts don’t cope well with a changed$IFS.