I know that to prepend/append something, I just have to do:
sed -i '/pattern/a new thing!'
However, I'd like to match a line, and prepend something two lines higher.
I'd like to limit tools only to those which come out of the box with ubuntu 12.04, I don't know if awk fits the bill.
Just in case I'm pursuing solution to problem B while I need solution to A: Excerpt of .m3u8 file looks like this:
#EXTINF:4.304300,
output-000.ts
#EXTINF:5.705700,
output-001.ts
#EXTINF:4.304300,
output-002.ts
#EXTINF:5.705700,
output-003.ts
Now, my goal is to insert a line 2 lines before every X'th output-XXX.ts. For example I want to achieve this:
#Inserted line 0
#EXTINF:4.304300,
output-000.ts
#EXTINF:5.705700,
output-001.ts
#Inserted line 1
#EXTINF:4.304300,
output-002.ts
#EXTINF:5.705700,
output-003.ts