LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Creating an alias (name=value pair) where the name has spaces. (https://www.linuxquestions.org/questions/linux-newbie-8/creating-an-alias-name%3Dvalue-pair-where-the-name-has-spaces-276512/)

Cubert 01-11-2005 08:59 AM

Creating an alias (name=value pair) where the name has spaces.
 
Hi,

Can an alias (in the .bashrc file) has one or more spaces in the name part of the name=value pair?

For example,

alias ls -l="ls -lh"

If yes, how?

Thanks and regards.

zeropash 01-11-2005 09:13 AM

I dont think what you asked can be done
however for what you intend in the example you can do a
alias ls=`ls -h`
ls -l would now be equal to ls -lh

another way of doing things is functions for example
for ex
unalias ls
function ls() {
if [ "$#" -gt 0 -a "$1" = "-l" ]; then
/bin/ls -h $*
else
/bin/ls $*
fi
}
or something like that

Cubert 01-12-2005 06:42 AM

Thanks zeropash.


All times are GMT -5. The time now is 10:14 AM.