fork download
  1. #!/bin/bash
  2. s='a~|~1~|~x
  3. b~|~1~|~y
  4. c~|~2~|~z'
  5. counter=$(awk 'BEGIN{FS="~[|]~"} $2==1{cnt++} END{print cnt}' <<< "$s")
  6. echo $counter
Success #stdin #stdout 0.01s 5604KB
stdin
Standard input is empty
stdout
2