in reply to Printing first and last line

perl -ne 'print if eof || $. == 1' my_file