Unix - Error while creating aliases.

April 6, 2011 at 23:05:55
Specs: Unix
Hi,

I am trying to create alias :
alias ls = 'ls -ltr'

but I am getting error

ls: ksh alias not found.
ksh: =: Invalid alias name.

Please help.
As I need to create aliases.


See More: Unix - Error while creating aliases.

Report •

#1
April 7, 2011 at 03:49:11
You don't say what Unix you are using, but on my FreeBSD system I get a similar error. The form of the alias command differs according to the shell that you are using (although I thought the form that you were using was correct for ksh). Anyway, try omitting the = sign:

alias ls 'ls -ltr'

That worked on my system.


Report •

#2
April 7, 2011 at 04:30:11
In the Korn shell, use:

alias ls="ls -ltr"

Don't use single quotes. Use double quotes.


Report •

#3
April 7, 2011 at 04:35:46
Thanks it works

Report •

Related Solutions

#4
April 7, 2011 at 06:58:19
Thru my own bad experience, I'd like to warn you that it is a really bad idea to alias common unix commands to act differently. It's a sure bet that sometime in the future, you'll run another shell script which will fail because it expects ls to act as originally designed.

Report •

Ask Question