Sign up ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

Is there anything to watch out for if you wanted to override ls? Is there a more reliable way of getting pagination out of ls?

For example:

function ls() { command ls -hp $@ | more; }
share|improve this question
You need to quote "$@". – jordanm Dec 1 '12 at 19:36

2 Answers 2

No harm doing it your way as it may be scoped to interactive shells and not impact scripts.

Only danger (and it may be a big one if you work on wide range of systems) - you may get used to a habit of using a non-standard mapping unnecessarily.

Particularly with ls there are some established best practices in the industry.

E.g. many systems implement ll as a pagination variant of ls. It's easier to type and you can reasonably expect it to be already present in a new system you encounter.

To see which shortcuts are readily available to you type alias and set.

share|improve this answer

You don't use ls in a script (don't parse ls), so that function will only be used by you in an interactive shell. Nothing to watch out for. Aside from adding double quotes around "$@", that's the best way to do it.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.