Reputation: 17
How to write regex in awk to find single quote (') and double quote (") for all lines in file. I want to print those lines
Upvotes: 0
Views: 1441
Reputation: 359
Using input.txt as example.
cat input.txt
result:
'hi sushma'
"second line"
third line
'last line'
You can search single quote using hexadecimal representation:
awk '/\x27/' input.txt
result:
'hi sushma'
'last line'
or search using scape character:
awk '/'\''/' input.txt
result:
'hi sushma'
'last line'
Finally, you can use the OR operator within the regex, for searching for both single and double quote:
awk '/'\''|\"/' input.txt
result:
'hi sushma'
"second line"
'last line'
Upvotes: 5