In one of my bash scripts, I am creating a file by repeatedly using echo with output redirection to append to the file. The resulting file, however, is not named properly, but always has an unprintable ^M character appended to the end. Does anyone know what I'm doing wrong? The following simple script demonstrates the problem:
#!/bin/bash
# Should create 'concat.txt' instead creates 'concat.txt^M'
outfile="concat.txt"
echo "'"$outfile"'"
for item in "Able" "Baker" "Charlie"; do
echo $item >> $outfile
done
System: Ubuntu 9.04 (x64)