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
  • 115,525
  • 42
  • 225
  • 281
workwise
  • 933
  • 15
  • 29

1 Answers1

6

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

Ignacio Vazquez-Abrams
  • 740,318
  • 145
  • 1,296
  • 1,325