Is there a Bash command to convert \r\n to \n?
When I upload my scripts from Windows to Linux, I need a utility like this to make things work.
|
Is there a Bash command to convert \r\n to \n? When I upload my scripts from Windows to Linux, I need a utility like this to make things work. | ||||
|
feedback
|
This question came from our site for professional and enthusiast programmers.
|
There is a unix utility called Additionally there are utilities called | |||
|
feedback
|
|
Using man 1 ed (which edits files in-place without any previous backup - unlike: sed .. -i ".bak" ...):
| |||
|
feedback
|
|
Translate (tr) is available in all Unixes:
| ||||
|
feedback
|
|
You can use this to bulk replace all lines in multiple files that end with
| |||||
feedback
|
|
(Each also exists for non-Ubuntu systems, but these links are handy.) | |||
|
feedback
|
dos2unixis usually available, otherwisesed -e 's/\r$//'– roe Jun 24 '10 at 14:17dos2unixwhich is a Unix/Linux program to do what you want. – Dennis Williamson Jun 24 '10 at 14:27