Results 1 to 3 of 3
Hi,
Under tcsh, I have an alias :
alias dir 'ls -al --color \!* | more'
I try to do the same under bash in a .profile file :
alias ...
- 10-24-2009 #1Just Joined!
- Join Date
- Oct 2006
- Posts
- 29
alias in bash shell
Hi,
Under tcsh, I have an alias :
alias dir 'ls -al --color \!* | more'
I try to do the same under bash in a .profile file :
alias dir='ls -al --color $1 | more'
but the behavior is not the same (and I want the tcsh behavior !!) :
Ex :
under tcsh :
# dir
total 68
drwxr-xr-x 11 apache apache 4096 2009-10-24 21:10 ./
drwxr-xr-x 19 root root 4096 2009-09-04 21:50 ../
-rw------- 1 apache apache 4885 2009-10-19 19:11 .bash_history
drwxr-xr-x 2 apache apache 4096 2009-09-04 21:38 cgi-bin/
# dir cgi-bin
total 12
drwxr-xr-x 2 apache apache 4096 2009-09-04 21:38 .
drwxr-xr-x 11 apache apache 4096 2009-10-24 21:10 ..
-rwxr-xr-x 1 apache apache 1075 2009-04-15 16:28 test.cgi
Under bash :
# dir
total 68
drwxr-xr-x 11 apache apache 4096 2009-10-24 21:10 ./
drwxr-xr-x 19 root root 4096 2009-09-04 21:50 ../
-rw------- 1 apache apache 4885 2009-10-19 19:11 .bash_history
drwxr-xr-x 2 apache apache 4096 2009-09-04 21:38 cgi-bin/
(Same as under tcsh : OK).
# dir cgi-bin
total 68
drwxr-xr-x 11 apache apache 4096 2009-10-24 21:10 ./
drwxr-xr-x 19 root root 4096 2009-09-04 21:50 ../
-rw------- 1 apache apache 4885 2009-10-19 19:11 .bash_history
drwxr-xr-x 2 apache apache 4096 2009-09-04 21:38 cgi-bin/
*** cgi-bin/: répertoire ***
I don't want the contents of . to be displayed.
I want the contents of cgi-bin to be displayed and they are not.
What am I doing wrong ?
Regards.
Xuo.
- 10-24-2009 #2Linux User
- Join Date
- Jan 2007
- Location
- cleveland
- Posts
- 452
try exposing the shell variable like this
alias dir='ls -al --color '$1' | more'the sun is new every day (heraclitus)
- 10-25-2009 #3Just Joined!
- Join Date
- Oct 2006
- Posts
- 29
Hi,
Your proposal does not work neither.
To make it work, I replaced the alias by a function :
dir() {
ls -al --color $1 | more
}
I search with Google and some people say it is not possible to pass arguments to an alias. I don't know if this is true.
This workaround works fine and I'll use functions to replace all the other aliases I have.
Thank you for your help.
Regards.
Xuo.


Reply With Quote