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.
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.
In the Korn shell, use: alias ls="ls -ltr"
Don't use single quotes. Use double quotes.
Thanks it works
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.
Yes (14) | ![]() | |
No (14) | ![]() | |
I don't know (15) | ![]() |