Linux: RHEL5 Tikanga Version: 2.6.18-402.el5 (per uname -a)
I'm creating a file by grepping some line from a windows source file (which contains some Version=x.x.x value) and putting it to new file aa.txt. This works fine for finding and grepping part. 
Doing it something like echo -n "AA "; echo "$(grep "Version=[1-9]" /some/mounted/loc/windows/sourcefile.txt) -" >> aa.txt. 
- I have to use echo -nforAAseparately i.e. I can't clubecho AAwithecho version partwith the latter echo command.
So, the resultant aa.txt file visually looks like this:
 Now, if I
Now, if I cat it, it doesn't print the first line, just the last - character.
If I use dos2unix (which actually works for removing the line ending character only and converts a Windows format file to a Linux line ending character format file), it's still not working as ^M in first line is not the last character in the line. PS: If you notice, the color of first ^M is different than the second line one, which I added manually by typing. 
Running od -cab aa.txt (octal dump) on this file, shows me that:
- for first - ^M, the characters are- \r,- cr spand- 015 040(i.e. carriage return and an invisible space character).
- for the second line, - ^M, is showing me normal values as- ^ M,- ^ Mand- 136 115(as I manually typed- ^and- Min the second line, this was expected).
Question:
1. Using tr -d '\r' < aa.txt > new.aa.txt I can solve this issue but what pattern I can use within vi or vim to remove this character in command mode.
Tried :%s/^M//g but it didn't catch the pattern.
 
     
     
    