1

I have several environment file, which end with .env. I want to find them in existing on the same directory shell scripts. I do

for i in [ ls -1 *env ]    
do
    grep $i *.sh >> ttt    
done    

It shows me the following errors:
grep: RE error 49: [ ] imbalance.
grep: illegal option -- 1
Usage: grep -hblcnsviw pattern file . . .

Could you please tell me where is my mistake?

0

Could you please tell me where is my mistake?

$ shellcheck myscript

Line 3:
    grep $i *.sh >> ttt    
         ^-- SC2086: Double quote to prevent globbing and word splitting.
            ^-- SC2035: Use ./*glob* or -- *glob* so names with dashes won't become options.

$ 

Source ShellCheck finds bugs in your shell scripts.

  • @osamuyl Do you need more help? If this was helpful to you and answered your question, please don't forget to accept it. See accept an answer. – DavidPostill Jan 31 '17 at 14:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.