awk
can match against a variable if you don’t use the //
regex markers.
if ( $0 ~ regex ){ print $0; }
In this case, build up the required regex as a string
regex = dom"$"
Then match against the regex
variable
if ( $1 ~ regex ) {
domain[dom]+=$2;
}
More Related Contents:
- Awk – replace coumn 2 in table 1 from coumn 2 in table 2 based on matching data in column 1 (common between tables)
- Find and kill a process in one line using bash and regex
- Why doesn’t `\d` work in regular expressions in sed? [duplicate]
- AWK: Access captured group from line pattern
- Split text by columns in PowerShell
- How to print matched regex pattern using awk?
- How to match a pattern given in a variable in awk?
- Sed to extract text between two strings
- string pattern matching using perl regex [closed]
- Why is this regex allowing a caret?
- Regex to validate date formats dd/mm/YYYY, dd-mm-YYYY, dd.mm.YYYY, dd mmm YYYY, dd-mmm-YYYY, dd/mmm/YYYY, dd.mmm.YYYY with Leap Year Support
- Regex: ignore case sensitivity
- Carets in Regular Expressions
- What is the ultimate postal code and zip regex?
- Negating a backreference in Regular Expressions
- regex to match a word with unique (non-repeating) characters
- Regex to split HTML tags
- Is it possible to define a pattern and reuse it to capture multiple groups?
- What’s the technical reason for “lookbehind assertion MUST be fixed length” in regex?
- Regular expression to match last number in a string
- R/regex with stringi/ICU: why is a ‘+’ considered a non-[:punct:] character?
- Matching math expression with regular expression?
- How do I use a regex in a shell script?
- How to search and replace with a counter-based expression in Vim?
- Combining $regex and $or operators in Mongo
- Case insensitive search in Mongo
- Why does VIM have its own regex syntax?
- Replace with whole match value using Notepad++ regex search and replace
- hgignore: help ignoring all files but certain ones
- Guide on how to use regex in Nginx location block section?