I encounter error when I use gawk. Below is the my script and example file Can you guys help me? I think regex is right but there is an error when it passed to the match function. I try various approach such as give \ to special character of regex or double .
$ cat script.sh
#!/bin/bash
gawk '
BEGINFILE{
while( getline < FILENAME > 0 ){
print match($0, /[0-9]+\.[0-9]+(?= ops/s)/)
print $0
}
}
' ./file
$ cat file
123.456: IO Summary: 123456 ops 1234.567 ops/s 100/100 rd/wr 1.0mb/s 1.111ms/op
$ sh script.sh
gawk: cmd. line:4: error: Unmatched ( or \(: /[0-9]+\.[0-9]+(?= ops/