[Top][All Lists]
[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 23:49:08 +0000 |
On Fri, Jan 1, 2010 at 7:18 PM, Peng Yu <address@hidden> wrote:
> On Thu, Dec 31, 2009 at 9:23 PM, James Youngman <address@hidden> wrote:
>> 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.
>
> This looks complicate for me to read. In order for me to understand
> how the above command does the job, do you have brief introductory
> material for findutils?
findutils comes with a manual ("info findutils") but you might be
better helped by reading an introduction to Unix which deals with
writing shell scripts.
James.