[Subject Prev][Subject Next][Thread Prev][Thread Next][Subject Index][Thread Index]

Re: Parameter passing to bash aliases



Hi Mathur,

These following lines in .bashrc solves it 100%.

cdnew ()
{
        \cd $* ; ls
}
alias cd='cdnew'

1.The \ in \cd $* is necessary.

2.There shall not be any double-quotes in "$*".
When I don't give any parameter it becomes
cd "";ls and it doesn't change the directory.

Thanks again,
Raja.



Raj Mathur wrote:
> 
> cdnew ()
> {
>         cd "$@"
> }
> 
> >>>>> "Rajasankar" == Rajasankar K <kraja@xxxxxxxxxxxx> writes:
> 
>     Rajasankar> Hello, I have a csh alias "alias cd 'cd \!*;ls'". This
>     Rajasankar> will change directory to the one specified in command
>     Rajasankar> line as parameter ( through !* ) and list the content
>     Rajasankar> of that directory.
> 
>     Rajasankar> Anybody know how to do this in bash? Any work-arounds?
> 
>     Rajasankar> Thanks Raja.
> 
> --------------------------------------------------------------------
> For more information on Linux in India visit http://www.linux-india.org/
> The Linux India mailing list does not accept postings in HTML format.

- --------------------------------------------------------------------
For more information on Linux in India visit http://www.linux-india.org/
The Linux India mailing list does not accept postings in HTML format.

------------------------------