Thanks for the reply Ulis.
OK, in the example I gave (i.e. the 'ls' command) it works OK. What I was doing was using 'ls' to help debug another problem. The technique you suggest doesn't appear to fix my original problem, which is this.
The command causing the problem is grep, not ls.
So what...