I have a file with records separated by empty lines, something like this:
ID0
field1
field2
field3
ID1
field1
field2
field3
ID2
field1
field2
field3
...
So, to get all content of a record based on its ID I use awk 'BEGIN {RS=""} /ID1/' file
But, the issue is that I would like to make it with a script, with the id passed as a variable.
I have written the script like that (but it doesn't work):
#! /usr/bin/awk -f
# Set Record Separator
BEGIN {RS=""}
# Search that record that contains the id
/id/
I call it with ./script.awk -v id=ID1 file
Any help?
Thanks!