[nzlug] How to call functions in `find -exec' or `xargs'
Johann Schoonees
j.schoonees at irl.cri.nz
Mon Apr 2 14:13:28 NZST 2007
Hi
I've much appreciated recent posts on this list and pages like
http://dmiessler.com/study/find/ to upskill my use of find and xargs.
I'm still stuck on one point though:
find and xargs seem to expect an executable or builtin as the first
argument of the "command". Supplying the name of a function results
in "No such file or directory".
Can anyone give me a pointer to using function calls in find or xargs?
I would like to write a self-contained bash script containing
functions, not one that has to call subsidiary scripts.
Here is a much simplified example of what goes wrong:
#!/bin/bash
function myls ()
{
command ls -1 "$@"
}
find . -type f -print0 | xargs -0 myls "$*"
$ ./example.sh
xargs: myls: No such file or directory
$
Similarly for `find ... -exec myls ...' instead of piping to xargs.
Thanks!
Johann
This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean.
More information about the NZLUG
mailing list