> grep -n -e '''' ^ '^' ^ $func ^ '''' $file /dev/null your problem is that you're constructing a list containing quotes suitable for input to the shell, but you really want to construct a list containing values suitable for arguments to grep. i think what you want is:
grep -n -e '^'^$func $file /dev/null which of course will only work correctly if $func contains no regexp metacharacters, but i'm sure you know that.
