The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Problem with GREP. syndex Shell Programming and Scripting 2 07-11-2007 01:44 PM
grep problem asal_email2 UNIX for Dummies Questions & Answers 4 06-22-2005 08:49 PM
grep problem svennie UNIX for Dummies Questions & Answers 5 11-08-2004 04:29 AM
Grep Problem lesstjm Shell Programming and Scripting 2 10-27-2004 10:13 AM
Grep problem odogbolu98 Shell Programming and Scripting 3 02-18-2003 03:53 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 11-30-2004
imppayel imppayel is offline
Registered User
  
 

Join Date: Nov 2004
Posts: 5
Unhappy grep problem. help!!!

i am writing a program that will search for a pattern in all the file in a particular directory and replace the pattern with a given pattern.
but the problem is this pattern i am searching may contain special characters like $,#,&,* etc.
but when the user is entering the pattern i dont want her to give the trouble of writing a backslash everytime he writes a special character. how can i modify my program so that i can trace the pattern with or without special characters without writing ' \' before every special character?
  #2 (permalink)  
Old 11-30-2004
zazzybob's Avatar
zazzybob zazzybob is offline Forum Advisor  
Registered Geek
  
 

Join Date: Dec 2003
Location: Melbourne, Australia
Posts: 2,100
If you don't need to worry about metacharacters at all, try "fgrep" (or grep -F on some systems) - this is "fixed" grep which greps for fixed strings.

Then
fgrep 'string$with&special*chars' file

would work and match the literal characters

EDIT: Please read the rules - duplicate and cross posting is not permitted. I have deleted the duplicate post from the Unix for Dummies forum. If somebody can provide an answer (as I have) - they will give it - duplicating posts does not safeguard a prompt response!

Cheers
ZB

Last edited by zazzybob; 11-30-2004 at 05:55 AM..
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 11:45 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0