Awk slash search pattern

Q awkIs there a way to map a pattern containing a forward slash /without actually slipping away from it?

awk '$1~/pattern/' file

The command above works fine, while not in the template /.

I am looking for something similar to what is available in sedfor using different delimiters in search and replace syntax.

Any help would be appreciated.

+4
source share
3 answers

Yes you can do

awk '$0~v' v="patt/ern"

Description

NB: extracted from the comments, so keep that in mind!

awk . OP , (. ).

+6

Debian Mawk , :

$ echo 'alfa / bravo' | awk '/[\/]/'
alfa / bravo

:

$ echo 'alfa / bravo' | awk '$0 ~ "/"'
alfa / bravo

:

$ echo 'alfa / bravo' | awk '/\57/'
alfa / bravo

mawk unescaped '/'

+3

?

kent$ echo "///aaa"|awk '/[/]/'
///aaa
+1

All Articles