Inspired by the success of my 'Awk One-Liners Explained' article (30,000 views in first three days), I decided to explain the famous sed one-liners as well.
Use sed command to delete / remove BOTH leading and trailing whitespace from each line including blank lines from a text file.
Remove ( color / special / escape / ANSI) codes, from text, with sed. Credit to the original folks who I've copied this command from. The diff here is.
Explains how to delete or remove ^M carriage return ( line feed) using sed under UNIX / Linux / BSD / Apple OS X operating systems.
You're parsing some text to extract the username from a domain\username string, most likely from Windows. Most of the above answers are only addressing your specific.
Right now I'm using echo 'Hello World' >> file.txt to append some text to a file but I also need to add text below a certain string let's say '[option]', is it.
You can either replace the backslash by a space as you show in the example result: sed 's/\\/ /g' or you can remove it as you show in your code.