[sf-lug] regular expression question

Nick James thenickjames at gmail.com
Fri Jun 8 13:53:37 PDT 2012

According to this page http://ss64.com/bash/alias.html bash aliases do not
accept arguments.  Here is the direct quote "There is no mechanism for
using arguments in the replacement text, as in csh. If arguments are
needed, a shell function should be used".  So it seems you were on the
right track when you created a function to accomplish this task.   You
stated that alias h='history | grep $1" works as an alias but there is no
guarantee that it will work every time.  That is my understanding. So if
you have any other aliases that take arguments, I would convert them over
to a function. Hope that helped.

On Fri, Jun 8, 2012 at 1:17 PM, James Sundquist <sundquistjames at gmail.com>wrote:

> So, I wrote some aliases that rely on user input that work just fine.
> alias h='history | grep $1"
> I tried doing the same thing for conducting quick google searches with the
> w3m pager, which can be used to browse text/html on the internet and is
> included on Ubuntu Server.
> $ w3m -dump -T text/html https://encrypted.google.com/search?q=news
>   This will output the results of searching the term "news" on google's
> search to the display. Works like a charm
> alias w3mtest='w3m -dump -T text/html
> https://encrypted.google.com/search?q="$1"'
>   I add this alias to bashrc and execute it with the argument "news"  and
> bash will not successfully interpret the input.  It outputs the Google
> search page and an additional line reading 'w3m: Can't load news'
> I've written this as a function and it works perfectly.  What is stopping
> this from working as an alias?  I'd love to get a fresh perspective.  I've
> gotten this concept to work in elinks by creating a bookmark for google
> search (g) and simply adding my search terms to the end of it.
> _______________________________________________
> sf-lug mailing list
> sf-lug at linuxmafia.com
> http://linuxmafia.com/mailman/listinfo/sf-lug
> Information about SF-LUG is at http://www.sf-lug.org/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://linuxmafia.com/pipermail/sf-lug/attachments/20120608/65e202d7/attachment.html>

More information about the sf-lug mailing list