#!/usr/bin/perl -n print if (/NAME/../SYNOPSIS/); # then: man ls | this_script.pl