Skip to content

Instantly share code, notes, and snippets.

@toonetown
Created February 21, 2020 18:07
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 toonetown/b529408d508180dfee742322b086e962 to your computer and use it in GitHub Desktop.
Save toonetown/b529408d508180dfee742322b086e962 to your computer and use it in GitHub Desktop.
Prints out all the c++ tokens (keying off ::) in a file
#!/bin/bash
[ -f "${1}" ] || { echo "Usage: ${0} <file>" >&2; return 1; }
cat "${1}" \
| sed -e 's|//.*$||g' \
| sed -e 's/::/xxDOUBLExCOLONxx/g' \
| perl -ne '{ print join("\n",split(/[[:^word:]]+/)),"\n"; }' \
| sed -e 's/xxDOUBLExCOLONxx/::/g' \
| grep '::' \
| grep -v '^::' \
| sort -u
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment