I am trying to put together a regexp inside of a grep statement to match
exactly one occurance of a string, but I can't quite get the syntax right. For
example, say I have the following in a file:
/usr/local/bin
/usr/local
/usr
/bin
/sbin/w
In this example, I want to only match the lines that have a single slash (/).
I've tried everything:
(e)grep '/\/{1}/' file
(e)grep "/\/{1}/" file
(e)grep '/{1}' file
(e)grep /\/{1}/ file
(e)grep "\/\{1\}" file
etc. . . . (note that in the above I tried both grep and egrep in every
case). I have gnu grep on my linux system.
I have a feeling that even if I do get the syntax correctly, which I believe
is the case in the last attempt above, it will still match all the above lines
because the exactly one occurance is on a per pattern basis. In other words:
grep "\/\{1\}" file
would match ./foo/bar
but not ./foo//bar
I instead need something which only matches one occurance of the pattern per
line . . . How would I do this?
TIA
sean
______________________________________________________________
#include "sig.h"
int main(){
if (feelingWitty) wittySig();
else standardSig();
return 0;}
/* Sean
*/