To get the size of all your files with awk, simply:
$ find . -name '*.java' -print0 | xargs -0 awk ' BEGIN { for (i=1;i<ARGC;i++) size[ARGV[i]]=0 } { size[FILENAME]++ } END { for (file in size) print size[file], file } '
To get the number of non-empty lines, simply create a line in which you increase the size [] conditionally:
$ find . -name '*.java' -print0 | xargs -0 awk ' BEGIN { for (i=1;i<ARGC;i++) size[ARGV[i]]=0 } NF { size[FILENAME]++ } END { for (file in size) print size[file], file } '
(If you want to consider lines containing only spaces as "empty", replace NF with /^./.)
To get only the file with the most non-empty lines, just change the settings:
$ find . -name '*.java' -print0 | xargs -0 awk ' BEGIN { for (i=1;i<ARGC;i++) size[ARGV[i]]=0 } NF { size[FILENAME]++ } END { for (file in size) { if (size[file] >= maxSize) { maxSize = size[file] maxFile = file } } print maxSize, maxFile } '
source share