Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can I disable regex in grep? 1

Status
Not open for further replies.

cpjust

Programmer
Joined
Sep 23, 2003
Messages
2,132
Location
US
Hi,
I'm wondering if there is any kind of switch to disable regex in grep? I couldn't see anything obvious in the man page.

I'm writing a script that greps for a certain string in a file and if it's not there, it adds it; but the string contains asterisks which grep considers wild cards. So right now I need to set 2 variables to the same string, except one has the * chars escaped so grep doesn't think of them as wildcards.

For simplicity & maintainability it would be nice if I could just use the same variable in the grep as I do when appending the string to the file.
 
Hi

man grep said:
-F, --fixed-strings
Interpret PATTERN as a list of fixed strings, separated by newlines, any of which is to be matched. (-F is specified by POSIX.)
Certainly works with GNU [tt]grep[/tt].

Feherke.
 
Hi

Ah, forgot it. Or on old systems use [tt]fgrep[/tt]. ( Which this days is considered deprecated and is just the same as [tt]grep -F[/tt]. )

Feherke.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top