Question

Is is possible to change the default regex delimiter (slash) to other characters?

I tried to do it using with sed syntax but it didn't work.

$ gawk '\|bash| { print } ' backup.sh
gawk: |bash| { print }
gawk: ^ syntax error

The regex I am trying has many slashes. Escaping all of them will make it ugly and unreadable. I tried changing the / to | but it didn't work.

TIA

Était-ce utile?

La solution

AWK doesn't support that. Use a variable instead.

gawk 'BEGIN {pattern = "/"} $0 ~ pattern {print}' backup.sh
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top