This is my try to do it
- Find all
*.java
files
find . -name '*.java'
- Count lines
wc -l
- Delete last line
sed '$d'
- Use AWK to find max lines-count in
wc
output
awk 'max=="" || data=="" || $1 > max {max=$1 ; data=$2} END{ print max " " data}'
then merge it to single line
find . -name '*.java' | xargs wc -l | sed '$d' | awk 'max=="" || data=="" || $1 > max {max=$1 ; data=$2} END{ print max " " data}'
Can I somehow implement counting just non-blank lines?
-print0
infind
in conjunction with-0
option inxargs
, something like this -find . -name '*.java' -print0 | xargs -0 wc -l | sort -n | tail -2 | head -1
– Rune