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.

2
  • 1
    what does pwd say about this? Commented Sep 23, 2013 at 7:46
  • Try to use absolute path eks: /var/Products/ Commented Sep 23, 2013 at 7:47

1 Answer 1

6

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

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks! That was indeed the problem!

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.