I have a script called script.sh:
FILE=$1
sed -i.bak "s|needle|pin|g" $FILE
If I run it like this:
bash ./script.sh /var/www/path/to/file
I get this response:
: No such file or directoryth/to/file
If I run sed
by itself, passing in the same path:
sed -i.bak "s|needle|pin|g" "/var/www/path/to/file"
It works fine (even substituting the values correctly).
What am I doing wrong?
Bonus observation: I'm assuming it's telling me the entry path is wrong but it's hard to tell because it says ": No such file or directoryth/to/file", which indicates to me that something else is wrong. Maybe something carriage-return related?