Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How can I search for a pattern in awk if the text contains special characters?

billinAddress ||

when I search, it is showing an error on pipe sign ||. How can I search for the pipe sign || in awk?

share|improve this question

migrated from serverfault.com Jan 14 '13 at 0:33

This question came from our site for system and network administrators.

You just need to escape them using \. So, instead of writing billinAddress ||, you need to write billinAddress \|\|.

For example, you can search for your pattern using:

awk '/billinAddress \|\|/{ print $0 }' /path/to/file
share|improve this answer
sgeorge-mn:~ sgeorge$ echo 'billinAddress ||' | awk '/\|\|/{ print $0 }'
billinAddress ||
sgeorge-mn:~ sgeorge$ echo 'billinAddress' | awk '/\|\|/{ print $0 }'
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.