bug-findutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to search for files that have fewer than n lines?


From: James Youngman
Subject: Re: How to search for files that have fewer than n lines?
Date: Fri, 1 Jan 2010 03:23:58 +0000

On Thu, Dec 31, 2009 at 10:05 PM, Peng Yu <address@hidden> wrote:
> I know I can used wc -l to get the number of lines in a file. Could
> somebody let me know how to search for files that have fewer than n
> lines? (n is a number)

min=73 # or whatever minimum you like.
find . -type f -print0 | xargs -r -0 wc -l /dev/null | awk -vn="$min"
'$2 != "/dev/null" && $2 != "total" && $1 < n {print $2;}'

The thing with the "/dev/null" there is to ensure that wc will always
print the filename (which it won't if there is always one argument) by
ensuring that wc is always passed more than one argument.

James




reply via email to

[Prev in Thread] Current Thread [Next in Thread]