Skip to main content
pass command line arguments through to the ls command
Source Link
Gilles 'SO- stop being evil'
  • 865.9k
  • 205
  • 1.8k
  • 2.3k

Sometimes an alias isn't powerful enough to easily do what you want, so here's a way without using them.

In some file that is sourced when your shell starts (e.g. .bashrc), add the following function:

ls () { echo "Hello world!" command ls "$@" } 

Unlike an alias, a function can recurse. That's why command ls is used instead of ls; it tells your shell to use the actual ls instead of the function you've just defined.

Sometimes an alias isn't powerful enough to easily do what you want, so here's a way without using them.

In some file that is sourced when your shell starts (e.g. .bashrc), add the following function:

ls () { echo "Hello world!" command ls } 

Unlike an alias, a function can recurse. That's why command ls is used instead of ls; it tells your shell to use the actual ls instead of the function you've just defined.

Sometimes an alias isn't powerful enough to easily do what you want, so here's a way without using them.

In some file that is sourced when your shell starts (e.g. .bashrc), add the following function:

ls () { echo "Hello world!" command ls "$@" } 

Unlike an alias, a function can recurse. That's why command ls is used instead of ls; it tells your shell to use the actual ls instead of the function you've just defined.

Source Link

Sometimes an alias isn't powerful enough to easily do what you want, so here's a way without using them.

In some file that is sourced when your shell starts (e.g. .bashrc), add the following function:

ls () { echo "Hello world!" command ls } 

Unlike an alias, a function can recurse. That's why command ls is used instead of ls; it tells your shell to use the actual ls instead of the function you've just defined.