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
Post a Comment