2

When I use tail file, tail by default prints the last 10 lines.

Is it possible to change that default in the system level?

7

No, the default number of lines produced by tail (and head) is mandated by the POSIX standard:

If neither -c nor -n is specified, -n 10 shall be assumed.

To get a different number of lines, use the -n command line option, or create a shell function:

mytail ()  { tail -n 5 "$@"; }

or, if you really want to keep the name of the utility and just change the default number of lines,

tail ()  { command tail -n 5 "$@"; }
4

No, but you can use alias.

Add to your .bashrc this string:

alias tails='tail -n 15'

...and run

$ source .bashrc

now every time you try to type:

$ tails file

you will get the last 15 lines of file

1

To do this you'd need to modify the source code and recompile it. But it looks like a waste of time and effort. Just use

tail -n 42

to output the last 42 lines.

0

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.