0

The bash file:

#!/bin/bash    
grep -l -r "products" Products/

gives output

: No such file or directory

When run directly from the terminal prompt, grep -l -r "products" Products/ gives the desired output, which is the list of files containing the word.

I checked using echo $SHELL that the shell is indeed bash so there should be no difference. What could be the reason? (Products/ directory contains around 3500 files).

Running on Ubuntu 12.04 LTS.

Yu Hao
  • 119,891
  • 44
  • 235
  • 294
workwise
  • 1,003
  • 16
  • 33

1 Answers1

6

Your script contains a CR at the end of the grep line. Use dos2unix to remove it.

Ignacio Vazquez-Abrams
  • 776,304
  • 153
  • 1,341
  • 1,358