Skip to content

Instantly share code, notes, and snippets.

@joshenders
Created March 26, 2015 00:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joshenders/2a7a7b00dc644a72b7a1 to your computer and use it in GitHub Desktop.
Save joshenders/2a7a7b00dc644a72b7a1 to your computer and use it in GitHub Desktop.
#!/bin/bash
# for each list of nodes in ISP metadata list
for country in metadata/by-isp/*; do
ccode="$(basename ${country})"
echo "${ccode}"
mkdir "by-isp/${ccode}"
# from node list for each country, create file with only tests from said country
pattern=$(awk '{ print $2 }' "${country}" \
| tr '\n' '|' \
| sed -e 's/\[/\\[/g' -e 's/\]/\\]/g' -e 's/|$//g')
egrep \"${pattern}\" by-month/february_noipv6.csv > "by-isp/${ccode}/february.csv"
# for each isp
while read line; do
node=$(awk '{ print $2 }' <<< "${line}" | sed -e 's/\]//g' -e 's/\[//g')
printf "[${node}] "
mkdir "by-isp/${ccode}/${node}"
egrep "\\[${node}\\]" "by-isp/${ccode}/february.csv" > "by-isp/${ccode}/${node}/february.csv"
done < "${country}"
printf "\n"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment