bdargan
bdargan

Reputation: 1349

limit the output of a command in a terminal based on lines displayable

Given an alias that lists last modified files, like this:

alias lt='ls -ltc|head -10'

is there a way to determine the lines displayable so I could have a filter/limit that is a function of that.

Not concerned about other issues like line-wrapping etc.

Upvotes: 1

Views: 610

Answers (2)

qqx
qqx

Reputation: 19475

The number of lines displayable on the current terminal is available in the $LINES variable.

Upvotes: 3

Olaf Dietsche
Olaf Dietsche

Reputation: 74078

You can get the terminal's size with:

stty size

which responds with number of rows and columns, e.g.:

25 80

And

stty size | awk '{print $1;}'

would give you just the number of lines.

Upvotes: 2

Related Questions