Running into a weird issue while running a docker container (Ubuntu). I copy in some scripts, those scripts should run read a file line by line and execute a command.
When I type out the commands in the shell, it works as I expect. When I have the exact commands in a .sh file, it fails. I've tried every iteration of While read, IFS, changing file permissions, checking spaces, delimiters, etc. Cant seem to make it work.
I'm sure is something simple, but I have yet to find it.
My script:
while read LINE;
do echo "$LINE";
done < "/megacmd/syncs"
Contents of syncs
file:
$ cat syncs
sourcedir1 destdir1
sourcedir2 destdir2
sourcedir3 destdir3
Output when running the script:
# pwd
/megacmd
# ls
exclude.sh excludes init.sh sync.sh sync2.sh sync3.sh sync4.sh syncs
# ./sync.sh
: No such filecannot open /megacmd/syncs
#
Why is there no space between filecannot?
Finally, when I'm manually writing this, it works fine:
# while read LINE;
> do echo "$LINE";
> done < "/megacmd/syncs"
sourcedir1 destdir1
sourcedir2 destdir2
sourcedir3 destdir3
#
edit1:
# ./sync.sh
: No such filecannot open /megacmd/syncs
# file syncs
syncs: ASCII text
#