Reputation: 1
I am trying to replace all my blank lines in a txt file with tags, so for example I have:
aaaaa
bbbbb
ccccc
and I want
<a>aaaaa</a><a>bbbbb</a><a>ccccc</a>
I have tried
sed 's/^\s*$/</a><a>/‘ file.txt
but it does not run, what instead should I do? thanks!
Upvotes: 0
Views: 430
Reputation: 1330
I have used below awk
command and it's working as expected.
awk 'NF{printf "<a>" "%s",$0 "</a>"} END {print ""}' test.txt
Output :
<a>aaa</a><a>bbbbb</a><a>ccccc</a>
Upvotes: 1