Monday, April 13, 2015

Recursively Find All Files With Only One Line Of Text On Linux

A nice one-liner for finding files that only contain a single line of text which is often the case with Wordpress exploits.
find . -type f -print0 | xargs -0 wc -l | awk '$1==1{print $2}'
...an alternate version:
find . -type f -exec sh -c '[ 1 -eq $(wc -l {}|cut -d" " -f1) ] && echo {}' \;