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.
Your script contains a CR at the end of the grep line. Use dos2unix
to remove it.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.