[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Handy Bash alias script



On 1/20/07, Wayne Topa <linuxone@intergate.com> wrote:
a.list.address@gmail.com(a.list.address@gmail.com) is reported to have said:
> On 1/19/07, Wayne Topa <linuxone@intergate.com> wrote:
> >a.list.address@gmail.com(a.list.address@gmail.com) is reported to have
> >said:
> >> On 1/19/07, cassiano <cassianoleal@gmail.com> wrote:
> >> >Why not just
> >> >
> >> >$ echo alias aliasname=\"alias commands\" >> ~/.bashrc
> >[--snip --]
> >> ...and have it work?  Aliases don't support $1 or $@, do they?
> >
> >They do here
> >alias deps='apt-cache showpkg $1'
> >alias policy="apt-cache policy $1"
> >alias 4page="a2ps --medium=Letter -4 $1"
>
> Ok, but how about one with $1 not at the end?  Like:
>
> alias testarg="echo $1 was the testarg"
>
> I get "bell-style was the testarg blah" when I run $(testargh blah).

Think about it.

I like to use real world examples.  If you want to play then
go ahead.

alias pslpt="cat $1 | psnup -2 -pletter | lpr"

Well, your real-world example won't do me any good, but here's something else:

alias uniqsort="cat $1 | uniq | sort"

So I run $(uniqsort filename) and I get:

cat: bell-style: No such file or directory
[many empty lines]
[the output of $(sort filename)]

It's still just tacking the argument onto the end of the alias.  Given
that, I don't see how your example would work either.  Are you using
bash?



Reply to: