Re: grep for metacharacters
- From: Doug Morse <morse@xxxxxxxxx>
- Date: Wed, 12 Sep 2007 02:34:43 +0000 (UTC)
very strange. have you tried quoting the regex:
grep -c "\t"
you probably know this, but just in case: if you're running this grep
from, say, a bash script, you might have to escape the escape
character:
grep -c \\t
and this can go on ad naseum, e.g., a subshell in a script might need:
`grep -c \\\\t`
also, i should point out that i didn't read your original post close
enough and that i should note a correction to it. "grep -c \t" will
count the number of LINES having a tab character, NOT the number of
tab characters (as you wrote).
lastly, i just ran "grep -c \t" and "egrep -c \t" on RHEL4 with a file
containing tabs and it worked just fine. seems like it's gotta be a
backslash escaping issue, or perhaps your file doesn't have any tabs?
On Tue, 11 Sep 2007 22:02:38 -0400, Tim Boyer <tim@xxxxxxxxxxxxxx> wrote:
On Wed, 12 Sep 2007 01:08:03 +0000 (UTC), Doug Morse <morse@xxxxxxxxx> wrote:
if available, use "egrep" instead
It is; doesn't work.
On Tue, 11 Sep 2007 20:54:52 -0400, Tim Boyer <tim@xxxxxxxxxxxxxx> wrote:
Other Unixes I've used have been able to grep for metacharacters. For
instance, to count the number of tabs in a document, you just do a
grep -c \t
or a \n for newlines, a \f for page feeds, etc.
Apparently, this doesn't work in Linux.
Is there any way to do this?
.
- Follow-Ups:
- Re: grep for metacharacters
- From: Tim Boyer
- Re: grep for metacharacters
- References:
- grep for metacharacters
- From: Tim Boyer
- Re: grep for metacharacters
- From: Doug Morse
- Re: grep for metacharacters
- From: Tim Boyer
- grep for metacharacters
- Prev by Date: Re: grep for metacharacters
- Next by Date: Re: grep for metacharacters
- Previous by thread: Re: grep for metacharacters
- Next by thread: Re: grep for metacharacters
- Index(es):
Relevant Pages
|