- 论坛徽章:
- 0
|
cardno.file 是进行匹配的帐号文件, 一个帐号一行, 注意最后一行请留一个空行.
条件过滤在# check filter condition注释下面一行, 可以根据情况调整.
data那里, 可以支持多个文件.
返回结果为ok: cardno或者failed: cardno.
根据你情况怎么玩都可以了.
- #!/bin/sh
- awk 'BEGIN {
- RS = "-+\n";
- FS = "\n";
- while (getline < "cardno.file")
- card_hash[$0] = "true";
- }
- {
- for (i = 1; i <= NF; i++)
- {
- if (split($i, tmp, ":|:") == 2)
- {
- hash[tmp[1]] = tmp[2];
- }
- }
- # check filter condition
- if (hash["cardno"] in card_hash && hash["stat"] == "success" && hash["tx
- kind"] == "取款")
- printf("ok:%s\n", hash["cardno"]);
- else
- printf("failed:%s\n", hash["cardno"]);
- }
- ' data
复制代码 |
|