[X-Unix] Bash alias help

William H. Magill magill at mcgillsociety.org
Wed Feb 25 17:46:22 PST 2004


On 25 Feb, 2004, at 02:43, Kirk McElhearn wrote:

> On 2/25/04 5:38 AM, "Brian Medley" <bpm-list-osx-unix at 4321.tv> wrote:
>
>>> I have the following alias for tcsh:
>>>
>>> alias dict ?curl -s dict://dict.org/d:\! <#_msocom_1>  :1 | egrep -v
>>>  '^22.*|^250.*|^150.*'"
>>>
>>> I want to rewrite this for bash, but, as far as I understand, \! 
>>> doesn't
>>> work in bash aliases. Does anyone out there who is a bash expert 
>>> know if
>>> this is correct? If so, how can I get this to work in bash?
>>
>> Are you trying to use arguments?  If so, this might be helpful from 
>> the
>> bash man page:
>>
>>   There  is no mechanism for using arguments in the replacement text.
>>   If arguments are needed, a shell function should be  used  (see
>>   FUNCTIONS below).
>
> Yes, that's what I found. The original tcsh alias has the argument \!. 
> Is
> there no way other than using functions? Because then it won't work as 
> an
> alias, right? It'd have to be a shell script, and that's something I 
> want to
> avoid.

This is what I use to replace \!* in one case. Don't know if it will 
work in yours or not.
(Complements of the ZSH mailing list.)

# -------------------------------------
#                      set bash defaults
# ------------------------------------- for the ls comand:
#     to get bash to do what tcsh does -- with:
#            alias ll        'ls -lag \!* | more'
#     this function, works with ksh, bash, zsh:

ll()
{
         /bin/ls -alsv $* | less
}
#


T.T.F.N.
William H. Magill
# Beige G3 - Rev A motherboard - 768 Meg
# Flat-panel iMac (2.1) 800MHz - Super Drive - 768 Meg
# PWS433a [Alpha 21164 Rev 7.2 (EV56)- 64 Meg]- Tru64 5.1a
# XP1000 - [Alpha EV6]
magill at mcgillsociety.org
magill at acm.org
magill at mac.com



More information about the X-Unix mailing list