Unix script appends ^M at end of each line
I'm not sure how echo
could be producing ^M
characters but you can remove them by running dos2unix
on your file, like this:
dos2unix /cust/vivek.txt
Only
sed -e "s/\r//g" file
worked for me
^M
is a carriage return, and is commonly seen when files are copied from Windows. Use:
od -xc filename
that should give a low-level list of what your file looks like. If you file does not come from Windows then another possibility is that your terminal setting are not translating correctly. Check that the TERM environment variable is correct.
If the file has come from Windows, then use dos2unix
or sed 's/\r//' file > file.new