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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with "\"

Status
Not open for further replies.

fabien

Technical User
Sep 25, 2001
299
AU

Hi,

I have the following expression in an AWK script
nocpy= "'.*\.(bri|cmp).*'"

this is to be used in a egrep -v statement

But when I print nocpy I get: '.*.(bri|cmp).*' The \ has disappeared, why?

If I do a simple test
toto = "\"
print toto

I get an error??

Thanks,
 
In your awk script do this:
Code:
nocpy="'.*\\.(bri|cmp).*'"
If for an egrep, simplier pattern:
Code:
nocpy="'\\.(bri|cmp)'"

Hope This Help
PH.
 
Tahnks but that did not work

nocpy="'\\.(bri|cmp)'"

print nocpy returns '\.(bri|cmp)'
 
The backslash \ is one of the escape symbols, which allows, for instance, a . (fullstop) to be treated as that character, and not as a one-character replacement in a regex
So, to escape the \, you need \\, then the \ will be printed.
HTH.

Dickie Bird (:)-)))
 
my mistake, it worked fine, thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top