I'm trying to make a script that runs through a list of paths provided from a file and edits a URL in each file, but I've run into a strange issue. Here's a reproducible example.
read -r line < paths.txt
echo $line
sed -i 's/word/otherword/' $line
The paths are coming from paths.txt, which simply contains one line that reads bat.properties
with a newline character.
The output of the script is below.
$ bash urlReplacer.sh
bat.properties
: No such file or directoryies
For reference, the error sed produces in this case would normally be sed: No such file or directory
. By changing the bat.properties
line, I've confirmed that the 'ies' in 'properties' is the part that's being appended to the end of the error, but I really don't know what's going on with the missing 'sed' at the beginning. As you can also see, bat.properties
is read in perfectly. I'm guessing this is an issue with sed misuse, but I'm not sure where the issue lies.