bash regular expressions
Ralph W. Reid
rreid at sunset.net
Wed Apr 6 02:35:39 EDT 2005
Your search strings are not in quotes, and are therefore interpreted
by the shell directly instead of by `grep`.. For this particular set
of cases, either single or double quotes will work. For differences
in the single and double quotes which can make a difference in other
cases, see the man page for the shell you are using (most likely
`bash). For the man page for `bash, enter the following command at
your system prompt:
man bash
Note that as I said before, the `bash` man page is somewhat lengthy,
but there is a lot of good stuff in there. Here is an example of one
command which solves one of your problems--I leave the other problem
for you to figure out as an exercise:
grep -c "\." ./testfile.txt
HTH, and keep on learnin' :) .
On Mon, Apr 04, 2005 at 10:22:11AM -0700, Ned wrote:
> Hi all,
>
> I wrote a bash script and all but the two commands below were marked wrong, so I need to correct them. Hope you don't mind pointing out my mistakes:
> 1. needs to output how many lines are there with a . (period) in them. I used the escape char \ before the period, but it apparently didn't work.
>
> echo Output the number of lines that have a \"\.\" \(period\):
> grep -c \. ./test.file
>
> 2. this one needs to output the number of lines containing the string '/*':
>
> echo Output the number of lines that have the string \"'/'\*\":
> grep -c /\* ./test.file
>
>
> Thanks a lot in advance!
> Ned
> _______________________________________________
> Speakup mailing list
> Speakup at braille.uwo.ca
> http://speech.braille.uwo.ca/mailman/listinfo/speakup
--
Ralph. N6BNO. Wisdom comes from central processing, not from I/O.
rreid at sunset.net http://personalweb.sunset.net/~rreid
...passing through The City of Internet at the speed of light!
CIRCLE AREA = _pi * r ^ 2
More information about the Speakup
mailing list