Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

10
  • So you are saying that if pattern was for example \d{3} to find three digits, that wouldn't work as expected, if I understood you well? Commented Mar 21, 2014 at 16:24
  • 2
    for \d which is not a valid C escape sequence, that depends on your awk implementation (run awk -v 'a=\d{3}' 'BEGIN{print a}' to check). But for \` or \b, yes definitely. (BTW, I don't know of any awk implementations that understands \d` as meaning a digit). Commented Mar 21, 2014 at 16:30
  • it says: awk warning - escape sequence \d' treated as plain d' d{3}, so I guess I would have a problem in this case? Commented Mar 21, 2014 at 16:34
  • 1
    Sorry, my bad, I had a typo in my answer. The name of then environment variable has to match ENVIRON["PATTERN"] for the PATTERN environment variable. If you want to use a shell variable, you need to export it first (export variable) or use the ENV=VALUE awk '...ENVIRON["ENV"]' env-var passing syntax as in my answer. Commented Mar 21, 2014 at 17:03
  • 2
    Because you need to export a shell variable for it to be passed in the environment to a command. Commented Mar 21, 2014 at 17:20