I have a script that expects files as arguments, and for each executes a set of instructions. How should I write it to be able to pipe it to find? In the example below, I haven't used find as such. I assume its output has the same structure as printf "%s\n..." (has it not?)
my-script.sh:
# !/bin/bash
help()
{
    echo "help"
    echo
}
while [[ $# -gt 0 ]]
do
    case $1 in
        *)
            echo "$1"
            shift # past argument
            ;;
    esac
done
Fine:
$ cat foo; echo; cat bar
foo  
bar
$ ./my-script.sh foo bar
foo
bar
But then:
$ printf "%s\n%s\n" "./foo" "./bar" | xargs -n 1 ./my-script.sh
./my-script.sh: 9: ./my-script.sh: [[: not found
./my-script.sh: 9: ./my-script.sh: [[: not found
my-script.shbut you're piping tofoo.sh. Can you show the actual code that is failing? You can also checkout shellcheck for help.cat my-script.sh# !/bin/bashis broken I think - you may have whitespace after#!but not between the#and the!. Likelyxargsis defaulting to/bin/shin this case - which doesn't support the ksh/bash/zsh[[ ... ]]extended test construct