bash - Substitute CarriageReturn with new line and pattern in VIM -


i have file.txt having 3 lines

line1 line2 line3 

while open file.txt in vim want substitute every cr(carriage return) new line having string "foo" , thing this.

$ cat file.txt line1 foo line2 foo line3 foo 

also looking possibility awk, sed , thing else in bash script.

with sed, if want replace carriage return foo :

sed 's/\x0d$/\nfoo/' file.txt 

to add line string foo after every line :

sed 's/$/&\nfoo/' file.txt 

Comments

Popular posts from this blog

PySide and Qt Properties: Connecting signals from Python to QML -

c# - DevExpress.Wpf.Grid.InfiniteGridSizeException was unhandled -

scala - 'wrong top statement declaration' when using slick in IntelliJ -