If I run this command it works fine in the terminal:
for dirname in $(ls -d dir/checkpoint/features.txt/20*);do;echo "hello";done But when run through /bin/sh -c it gives an error
/bin/sh -c "for dirname in $(ls -d dir/checkpoint/features.txt/20*);do;echo "hello";done" ERROR:
/bin/sh: -c: line 1: syntax error near unexpected token `dir/checkpoint/features.txt/201108000' /bin/sh: -c: line 1: `dir/checkpoint/features.txt/201108000' My default shell is /bin/bash. I cant seem to understand what is causing this. My default implementation for running all shell commands in my program is by appending /bin/sh -c to them. It is the first time i am seeing this issue. Any suggestions?
/bin/shthe same as/bin/bash? On (older versions of) Solaris, for instance,/bin/shis not a POSIX shell and does not recognize$(...)notation. Did you try enclosing the command in single quotes.