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*

1
  • Thanks. (1) If I am correct, in a pattern-action statement, the pattern can be an expression which can be a regular expression or not a regular expression. So using a variable as a pattern is not using it where only regular expression is expected. That's the reason of it not working. (2) For RE='\.txt$' awk '$0 ~ ENVIRON["RE"] {...}', can I just use awk -v RE='\\.txt$' '$0 ~ RE {...}' (doubling the backslash) equally well? Commented Nov 15, 2018 at 21:14