perl -ne '$a[$i=$.%4]=$_; print @a[$i+1..$#a,0..$i], "--\n" if /regex/' file