On Thu, 11 Jan 2007, Mike Miller wrote: > This should do it: > > perl -pi -e 'BEGIN{undef $/} ; s/\A(.+?%%EOF).*\z/$1\n/gs' *.pdf By the way, that alters the files in place -- replacing the original with the repaired version. If you want to retain the originals with a .bak extension, do this: perl -pi.bak -e 'BEGIN{undef $/} ; s/\A(.+?%%EOF).*\z/$1\n/gs' *.pdf Mike