I want to search for pattern and if matched then print the matched line and previous line. I used code
awk '/pattern/ {print a}{a=$0}' file
But it is only printing the previous line of matched line. How can I print print previous line along with matched line.