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; }
  • 5
    You need to quote "$@".
    – jordanm
    Dec 1 '12 at 19:36

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.


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.

Your Answer

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