Reputation: 379
I am using egrep to look through scripts in our perforce NAS.
i am trying to find where we use RCP & RSH....The problem i have is that 1) I suck at REGEX; 2) i am picking up junk I am not interested in. For example if a file has the word strcpy..it picks up on RCP..or ownership..hits on RSH.
Obviously i am not interested in those, but I don't want to exclude lines based on the words ownership or strcpy...because they may be used in conjunction...and its not a complete list.
Here is my regex
'ftp|rcp|rsh'
How can mod these to hit on FTP, but not SFTP...rcp but no strcpy, rsh but not ownership.....etc.?
So Things I would want to match.
ftp
`ftp`
/ftp/
"PUNCT"FTP"PUNCT"
Upvotes: 5
Views: 6823
Reputation: 265151
There are several metacharacters:
\b
word boundary\<
word start\>
word endSo, one possible regex is: \<(ftp|rcp|rsh)\>
Upvotes: 6
Reputation: 3682
Maybe you need something like this:
\b
< - this is the border of word
\bpattern\b
<- this pattern will match only pattern
, but not otherbigpatternthatyounotneed
Upvotes: 8