Glam Prestige Journal

Bright entertainment trends with youth appeal.

in grep command I can set max line to output with parameter -m. How I can specify max line in cat command ?

2 Answers

cat is dedicated to whole files.

You are looking for either head or tail, depending if your counting starts from the beginning or end of a file.

Examples

  • head --lines=100 print the first 100 lines
  • head --lines=-100 print all but the last 100 lines
  • tail --lines=100 print the last 100 lines
  • tail --lines=-100 print all but the first 100 lines

Note

You may also have a look at tac. The result is clear, if you compare the word tac with cat.
tac prints out all lines in reverse ordering.

2

Use head -n $NUMBER_OF_LINES instead of cat.

And watch out for useless uses of cat.

1

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy