I\'m looking for a way to limit the amount of output produced by all command line programs in Linux, and preferably tell me when it is limited.
I\'m working over a s
Making aliases of all your commands would be a good start. Something like
alias lm="ls -al | more"
alias cam="cat $@ | more"
this makes me think of bash-completion.
As complete command in bash enables you to specify handler when a program is not found,
what about write your own handler and clear $PATH, in order to execute every command with redirection to a filtering pipe?
#Did not try it myself.
Assuming you're working over a network connection, like ssh, into a remote server then try piping the output of the command to less. That way you can manage and navigate the output from the program on the server better. Use 'j' and 'k' to move up and down per line and 'ctrl-u' and 'ctrl-d' to move 1/2 a page up and down. When you do this only the relevant text (i.e. what fits on the screen) will be transmitted over the network.
I don't know about the general case, but for each well-known command (cat, ls, find?) you could do the following:
So along these lines (utterly untested):
$ ln `which cat` ~/bin/old_cat
function trunc_cat () {
`old_cat $@ | head -n 100`
}
alias cat=trunc_cat
Perhaps using screen could help?