Using Awk I want to match the entire record using a regular expression. By default the regular expression matching is for parts of a record.
The ideal solution would:
- Be general for all fields, regardless of the field separator used.
- Not treat the entire input as a single field and parse it manually using string functions.
- Work in a general way and not be specific to gawk for example.
However any and all solutions are of interest as long as they use Awk without calls to external programs.
An example, I have:
$ ls indata.txt t1.awk $ cat indata.txt a1010_ 1010_ 1010_b $ cat t1.awk /[01]*_[01]*/ { print $0 }
I get:
$ awk -f t1.awk indata.txt a1010_ 1010_ 1010_b
This is the result I am seeking:
$ awk -f t1.awk indata.txt 1010_
You just need to add a beginning and end anchor to your regex: