Removing Characters Caused by an FTP
Using FTP in binary mode to transfer text files or tar files from a PC to a Unix system can cause your files to contain many ^Z and ^M (or carriage return) characters. These can cause problems when compiling those files.
To remove these characters, use the following script:
sed 's/^M//;s/^Z//' $1 > $1.new
The ^M and ^Z characters in the script are achieved by typing the following:
ctrl-V (for the ^) and ctrl-M (for the M)
ctrl-V (for the ^) and ctrl-Z (for the Z)
Important!: You cannot simply cut and paste this script. You must manually type the escape character (ctrl-V), then the appropriate character (ctrl-M or ctrl-Z) for this script to work properly.
If you name this script my_script and would like to use it on the file called my_file, simply type my_script my_file, and the new edited file will be named my_file.new.