in reply to How to get previous line of the file while processing current line in while loop
Possible heresy
If its just for a trivial *nix sysadmin task, you could do worse than man grep and check out some options including -A