Rosetta Code/Count examples: Difference between revisions
→{{header|UNIX Shell}}
Line 3,037:
API=$SITE/mw/api.php
PAGES=$SITE/mw/index.php
query="$API?action=query"
query+=$(printf '&%s' \
Line 3,043 ⟶ 3,042:
cmtitle=Category:Programming_Tasks \
cmlimit=500)
total=0
while read title; do
Line 3,051 ⟶ 3,049:
printf '%s: %d examples.\n' "$title" "$tasks"
let total+=tasks
done < <(curl -s "$query&format=json"
| jq -r '.query.categorymembers[].title')
printf '\nTotal: %d examples.\n' "$total"</lang>
|