Skip to content

Instantly share code, notes, and snippets.

@johan
Last active August 20, 2017 08:14
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 johan/354391bcd611efda77d98015de435e52 to your computer and use it in GitHub Desktop.
Save johan/354391bcd611efda77d98015de435e52 to your computer and use it in GitHub Desktop.
#! /bin/sh
# path to your unzipped Facebook html/friends.htm file
friends="$1"
year=$(
egrep -o '<div class="footer">Downloaded by .* on \w+, \d+ \w+ (\d+)' "$friends" \
| awk '{print $NF}'
)
echo 'date,name'
perl -pe 's:^.*?</ul>(.*?)</ul>.*:\1:' < "$friends" \
| tr '<' '\n' \
| sed -n '/^li>/s/^...//p' \
| sed -E 's/([a-z])\)$/\1 '${year}')/' \
| sed -E 's/^(.*) \(([0-9]+) (...)[a-z]* ([0-9]+)\)/\4-\3-\2,\1/' \
| sed -E 's/^([0-9]+)-(...)-([0-9]),/\1-\2-0\3,/' \
| sed -e 's/&#064;/@/g' -e "s/&#039;/'/g"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment