Quantcast
Channel: Active questions tagged bash+awk - Ask Ubuntu
Viewing all articles
Browse latest Browse all 102

Add specific text/tag after every few lines in bash

$
0
0

I have a text file where I have to add tags (in the form of normal text) to a .txt file.

For example, suppose I have a text file like this:

a
b
c
d
e
f
g
h

I want to add the tags <hello> and </hello> before and after every 3 rows, respectively, and make it look somewhat like this:

<hello>
 a
 b
 c
</hello>
<hello>
 d
 e
 f
</hello>
<hello>
 g
 h
</hello>

How can I achieve this?


Viewing all articles
Browse latest Browse all 102

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>