Answers for "linux replace string with newline"

0

replace a newline using sed linux bash

$ echo 'foo
bar
baz

foo2
bar2
baz2' 
| tr 'n' '00' 
| sed 's:x00x00.*:n:g' 
| tr '00' 'n'
Posted by: Guest on October-10-2021
0

replace a newline using sed linux bash

# sed is intended to be used on line-based input. Although it can do what you need.
#A better option here is to use the tr command as follows:
tr 'n' ' ' < input_filename

#or remove the newline characters entirely:
tr -d 'n' < input.txt > output.txt

#or if you have the GNU version (with its long options)
tr --delete 'n' < input.txt > output.txt
Posted by: Guest on October-10-2021

Code answers related to "linux replace string with newline"

Code answers related to "Shell/Bash"

Browse Popular Code Answers by Language