#!/bin/bash # print the SYNOPSIS section of a man page # Mikel Ward man "$@" | perl -n -e ' BEGIN { $synopsis = 0; } if (/^SYNOPSIS/) { $synopsis = 1; print "\n"; next; } elsif ($synopsis == 0) { next; } elsif (/^[A-Z]{2,}/) { exit; } else { print; } '