I want to find a line in a txt file and then insert string 3 lines above the found line
Input:
aaa
bbb
ccc
ddd
eee
fff
I want to look for “eee” and then print “WWW” 3 lines above it. Output:
aaa
WWW
bbb
ccc
ddd
eee
fff
I’m using awk and can only print “WWW” 1 line above “eee”, and not 3:
awk '/eee/{print "WWW"} 4' file.txt
any ideas?
One way: