Linux command sed - Remove Windows specific line returns

Overview

sed is a stream editor. This is used to perform text transformations of an input stream, such as a file or a pipeline. Files created on the Windows operating system contain line returns that prevent the execution of scripts on a Linux operating system.

Remove line returns

Execute sed with the following operation to remove the windows generated line returns:

sed -i 's / \ r // g' sample.sh

Conclusion

The sed command sets the operation to be executed in single quotes followed by the file. The s is the substitution. Found matches are addressed by ` // . Specifying the replacements pattern by using ` / `. In this case, ` \ r `, the line break, is replaced by nothing. The parameter `g instructs sed to search for all occurrences.

To top