<div dir="ltr"><div><div>Did you copy-past that if-statement wrong?<br></div>You're missing a closing ] <br><br></div>-> Jake<br></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, Dec 6, 2013 at 2:09 PM,  <span dir="ltr"><<a href="mailto:canito@dalan.us" target="_blank">canito@dalan.us</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">In the process of writing a script which I would like to count the number matched patterns (command line parameters).<br>

<br>
The issue I am running into using grep is that the string has a dash in front, and it throws an error.<br>
<br>
E.g:<br>
<br>
./script -test<br>
<br>
PATTERN=$1<br>
<br>
egrep -ic $PATTERN --> egrep: invalid option -- 't'<br>
<br>
awk and egrep work using a file, but not on a variable:<br>
<br>
EXAMPLE=`awk '/test/ { nlines++ } {print nlines}' $PATTERN`<br>
<br>
awk: cmd. line:1: fatal: cannot open file `-test' for reading (No such file or directory)<br>
<br>
I know using and if command works, so am I just over doing it? What am I doing wrong?<br>
<br>
if [[ $PATTERN == "-test" ]; then<br>
<br>
Thanks in advanced!<br>
<br>
Saul David Alanis<br>
<br>
<br>
<br>
<br>
______________________________<u></u>_________________<br>
TCLUG Mailing List - Minneapolis/St. Paul, Minnesota<br>
<a href="mailto:tclug-list@mn-linux.org" target="_blank">tclug-list@mn-linux.org</a><br>
<a href="http://mailman.mn-linux.org/mailman/listinfo/tclug-list" target="_blank">http://mailman.mn-linux.org/<u></u>mailman/listinfo/tclug-list</a><br>
</blockquote></div><br></div>