LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Hyperactive alias overrides all command line flags. (https://www.linuxquestions.org/questions/linux-newbie-8/hyperactive-alias-overrides-all-command-line-flags-618569/)

philwynk 02-04-2008 08:04 AM

Hyperactive alias overrides all command line flags.
 
Simple question:

I've aliased "ls" to "ls -altr". I like that display.

Only, now that I've done that, "ls" ignores command line switches, and ALWAYS gives me "ls -altr". I should be able to type "ls -alt" and get the display in the reverse order, or "ls -lr" and not see the "." and ".." entries; but for some reason, now that I've aliased "ls", I get the same display no matter what switches I type.

Any idea why it's doing that? Any suggestion how to get it to stop, aside from removing the alias and typing the entire command every time?

Thanks.

Phil W.

Simon Bridge 02-04-2008 08:43 AM

It does that because every time you type "ls" the computer expands this to "ls -altr" so when you type "ls -lr" it is actually "ls -altr -lr" get it? It's like a macro.

That is also why your ~/.bashrc file has different alias names for different effects.
So, alias ls to whatever you use practically all the time, then add other aliases for what you use less often.

lt = ls -alt
lr = ls -lr

philwynk 02-04-2008 08:59 AM

Duh... thanks.

Simon Bridge 02-04-2008 07:04 PM

No problem - we all get to ask dumb questions sometimes: have a look at my early posts ;)

The effect is general. Now you have asked, and received this wisdom, you know in your bones a useful paradigm. You are now a little bit smarter. Have fun.

"Remember children, there are no stupid questions, only stupid people."
-- Mr Garretson: South Park.


All times are GMT -5. The time now is 05:38 PM.