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

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


No, but you can use alias.

Add to your .bashrc this string:

alias tails='tail -n 15'

relogin at the server and try to type:

tails file

And you will get the last 15 lines of file

| improve this answer | |

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 "$@"; }
| improve this answer | |

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.

| improve this answer | |

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.