#!/bin/bashs='a~|~1~|~xb~|~1~|~yc~|~2~|~z'counter=$(awk 'BEGIN{FS="~[|]~"} $2==1{cnt++} END{print cnt}' <<< "$s")echo $counter
Standard input is empty
2
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!