I have the following script that reads through a file line by line
_PATH=$(pwd)
LOCATION_PATH="$_PATH/inventory.sh"
LETTER="l"
while IFS='' read -r line || [[ -n "$line" ]]; do
echo $line >> file2.test
CALL="${LOCATION_PATH} ${line} ${LETTER} 1234"
echo $CALL >> file.test
echo =========
RESULT=$($CALL)
#echo $RESULT
done < "$1"
But while the input file for each line has NO ^M
(carriage return) character in it, the output of the file.test file has them as follows:
/.../inventory.sh 00000e99-bce9-11e4-8418-06e8ce2b06d8^M l 1234
/.../inventory.sh 0001688b-bce7-11e4-8418-06e8ce2b06d8^M l 1234
The output to file2.test alos has no ^M
character.
I have tried substituting as follows:
SP=" "
LE="l"
...
CALL="${LOCATION_PATH}${SP}${line}${SP}${LE}${SP}1234"
To no avail.
dos2unix
to convert the file into an Unix readable file. – mathB Oct 19 '17 at 09:26sed -n l filename
to make invisible characters visible. – Philippos Oct 19 '17 at 09:27file2.test
output file. Unless you present evidence that you have checked correctly, I’m going to assume that they all have CRs. (2) You should probably use more quotes. – G-Man Says 'Reinstate Monica' Oct 19 '17 at 09:43^M
, while at the end of the line they are typically hidden. So please verify your assumption with the givensed
command. – Philippos Oct 19 '17 at 10:07