referring to arguments in bash aliases

Timothy Stone citylists at petmystone.com
Thu Mar 4 08:14:01 UTC 2004


Timothy Stone wrote:

> List,
> 
> tcsh user moving to bash.
> 
> What is the bash equivilent to:
> 
> alias llm 'ls -l \!* | less'
> 
> I got this far:
> 
> alias llm="ls -l | less"
> 
> How do I perform things like: \!*, \!^, \!$, \!:n ? Is it as simple as 
> $1? How do I refer to the first or last arguments (\!^ and \!$ in tcsh)?

Hmmm...  man bash states that, "There  is no mechanism for using 
arguments in the replacement text.  If arguments are needed, a shell 
function should be used (see  FUNCTIONS below)."

Boo. :( Now, how do I write a simple shell function in bash?

I've got this far:

llm() { }

It's a start right? ;) Am I headed down the right path? Did I read to 
much between the lines in the man pages for bash? Nothing on the web 
dives this far into aliases in bash. Much seems to skip arguments in the 
alias' replacement text.

Again,
> 
> Many thanks in advance,
> Tim





More information about the redhat-list mailing list