sed -i.bak 's/\r$//' file.txt
Here is what the above code is Doing:
1. sed is a stream editor.
2. -i.bak is the in-place edit option. It means that the file will be edited in place, and a backup file will be created with the extension .bak.
3. ‘s/\r$//’ is the substitution command. It means that the last character of each line will be replaced with nothing.
4. file.txt is the file to be edited.