Skip to content

Instantly share code, notes, and snippets.

@klainfo
Created June 18, 2015 15:43
Show Gist options
  • Save klainfo/e37c8dcbf7037a834290 to your computer and use it in GitHub Desktop.
Save klainfo/e37c8dcbf7037a834290 to your computer and use it in GitHub Desktop.
# C++ functions parser
# Reference: http://stackoverflow.com/questions/6133989/what-grep-command-will-include-the-current-function-name-in-its-output
# Usage: ./cpp-parser.sh <file.cpp>
awk -v re='return' '/^[[:alpha:]]/{f=FNR"-"$0} $0~re{printf "%s\n%d:%s\n--\n",f,FNR,$0; f="" }' $1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment