The $
does not represent a character. It simply shows where the line ends.
The purpose of this is to show trailing whitespace, like in this example explaining uniq
output:
$ uniq file
foo
foo
$ cat -vE file
foo$
foo $
Since it's just a visual marker, asking how to delete it doesn't make sense. It was never there. If you want \r\n
, then ^M$
is correct. Here's an example of this, verifiable by the hex dump:
$ cat -vE file
foo^M$
bar^M$
$ od -c -t x1 < file
0000000 f o o \r \n b a r \r \n
66 6f 6f 0d 0a 62 61 72 0d 0a