Skip to content

Instantly share code, notes, and snippets.

@ottijp
Created October 28, 2024 13:10
Show Gist options
  • Save ottijp/070582f0537cf8f57cf11a85e96fdb66 to your computer and use it in GitHub Desktop.
Save ottijp/070582f0537cf8f57cf11a85e96fdb66 to your computer and use it in GitHub Desktop.
YN Stats script
ユーザーA: YYYYN
ユーザーB: NNYNN
ユーザーC: YNYNY
ユーザーD: YYNNY
ユーザーE: NYYYY
ユーザーF: YNYYN
ユーザーG: NNNNN
ユーザーH: YYYYN
ユーザーI: NYNYN
ユーザーJ: YNYYY
cat chat-history.txt | ./yn-stats.sh
#!/bin/bash
grep -oE '[YN]{5}' | tr YN 10 |
awk '{
for (i = 1; i <= 5; i++) sum[i] += substr($0, i, 1)
}
END {
for (i = 1; i <= 5; i++) printf "%d: %d (%.2f%%)\n", i, sum[i], (sum[i] / NR) * 100
}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment