Skip to content

Instantly share code, notes, and snippets.

@anuragpeshne
Created April 9, 2015 06:24
Show Gist options
  • Save anuragpeshne/110b6618e4b4a1f2397b to your computer and use it in GitHub Desktop.
Save anuragpeshne/110b6618e4b4a1f2397b to your computer and use it in GitHub Desktop.
bash to find up largest variable name in PHP and JavaScript
egrep -oshRI --include \*.php '(\$[a-zA-Z_0-9]+)' ./ | awk -F ':' '{ print length $1}' | sort -gr | head -n 1
#this will output largest PHP variable name
egrep -shIRo --include \*.js '(?:[\n\( ])([a-zA-Z_0-9]+) *=' ./ | awk '{ print length, $1}' | sort -gr | head -n 1
#this will output largest JavaScript variable name
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment