Answers for "how to add new lines for every nth line in linux"

0

how to add new lines for every nth line in linux

sed '0~2G' file

sed '1~1G' file # for every line

eg : sed -e "s/T1/Title/g" -e "s/N2/abstract2/g" -e '1~1G' new.ris


here: 
aaa
bbb

ccc
bbb



'startline ~ nstep G'
Match every step'th line starting with line first. For example, ``sed -n 1~2p'' will print all the odd-numbered lines in the input stream, and the address 2~5 will match every fifth line, starting with the second. first can be zero; in this case, sed operates as if it were equal to step. (This is an extension.)
Posted by: Guest on July-28-2021

Code answers related to "how to add new lines for every nth line in linux"

Code answers related to "Shell/Bash"

Browse Popular Code Answers by Language