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?
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.
Sign up to join this communityYou 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
sgeorge-mn:~ sgeorge$ echo 'billinAddress ||' | awk '/\|\|/{ print $0 }'
billinAddress ||
sgeorge-mn:~ sgeorge$ echo 'billinAddress' | awk '/\|\|/{ print $0 }'