So, I have a file called "burpfile". I want to add a specific line "peter" after every second line. An example burpfil can contain:
line1
line2
line3
line4
line5
I want the bashscript to modify it to become:
line1
peter
line2
peter
line3
peter
line4
peter
line5
peter
To realise this I have tried sed, since that was the choice in this post: https://stackoverflow.com/a/45964337/11155582
This is what I have got so far. However, since I don't understand sed the script only inserts "peter" at the end of the file. And I don't know why.
nr=$(wc -l burpfil | awk '{print $1}')
for i in $(seq 0 2 $nr)
do
sed -e '$i peter' -i burpfil
done
As seen in the codesnippet the command doesn't resemble what is in the thread I linked to. That is because having a variable in the command doesnt work... And I don't know how to get around it.