Alex Rivera | Logout

unix - head AND tail of file

Asked 2011-12-24T12:59:07.157
179

What is the command to view the top 10 lines and bottom 10 lines of file simultaneously?

Edit
Report

1 Answer

1

First 10 lines of file.ext, then its last 10 lines:

cat file.ext | head -10 && cat file.ext | tail -10

Last 10 lines of the file, then the first 10:

cat file.ext | tail -10 && cat file.ext | head -10

You can then pipe the output elsewhere too:

(cat file.ext | head -10 && cat file.ext | tail -10 ) | your_program

answered 2011-12-24T13:03:22.500

Your Answer