Regular Expressions as command line paramteters

Use and complete the template provided. If you don't, your post may be deleted!

  1. The problem statement, all variables and given/known data:
    We have to write a program that uses wget to get pages of a URL and search them for a pattern.

the command for the script should will look like this
> Look4Pattern URL E [L]
URL - url to search
E - string or regular expression to search for (10pts more for regular expression)
L - if not given then search only root level, otherwise recursively search L levels.

  1. The attempts at a solution (include all code and scripts):

I have it working fine except when entering a regular expression, if the bar "|" is used, it is interpreted as a pipe instead of an argument, thus if I enter
Look4Pattern Yahoo! grey|gray 1
I would get an error message
bash: gray: command not found

is there anyway to get around this other than make the user enter regular expressions in quotation marks?

  1. School (University) and Course Number:

you use the "|" as a pipe in your command. but without seeing the whole code we can't help you further...

You have to keep the shell from parsing the pipe symbol:

$ echo grey|gray
bash: gray: command not found
$ echo 'grey|gray'
grey|gray

Sorry,
I did not think the code was relevant. Thank you for taking the time to help me.

#! /bin/bash
mkdir wGetResults
cd wGetResults
cWd1=`pwd`
if test "$#" = 2
then
    tryCmd="wget "$1
fi
if test "$#" = 3
then
    tryCmd="wget -r -l"$3" "$1
fi
gRepper="egrep -r -l -e "$2" "$cWd1"/"
$tryCmd
$gRepper

how do you call the script? give an example with the output...

Thank you for all of your help, I think pludi answered my question.