Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
How can I remove the control character '^M' at the beginning of a file?
The '^M' is the only character at the top of the file.
I want to delete the line that contains this topmost '^M' without removing other '^M's in the file.
Also, I do not want to replace the '^M' with a blank line just delete the whole line.
thanks.
# just delete the first char if it is ^M
perl -pi.bak -e "$i++ || s/^\r//" <filenames>
# delete the entire first line if it starts with ^M
perl -pi.bak -e "$i++ || s/^\r.*\n//" <filenames>