help-bash
[Top][All Lists]
Advanced

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

Re: Check if file size greater than a small number?


From: Alex fxmbsw7 Ratchev
Subject: Re: Check if file size greater than a small number?
Date: Thu, 10 Mar 2022 03:16:55 +0100

minsize() { < <( LC_ALL=C find "${@:2}"  -printf %p\\0%s\\0\\0 ) gawk -v
RS=\\0\\0 -v FS=\\0 -v min=$1 '$2 <= min { print $1 }' ; }

On Thu, Mar 10, 2022 at 3:15 AM Alex fxmbsw7 Ratchev <fxmbsw7@gmail.com>
wrote:

> and clean up
> last mail
> cheers
>
> minsize() { < <( LC_ALL=C find "${@:2}"  -printf %p\\0%s\\0\\0 ) gawk -v
> RS=\\0\\0 -v FS=\\0 -v min=$1 'BEGIN { while ( getline <"/dev/stdin" ) if (
> $2 <= min ) print $1 ; exit }' ; }
>
> On Thu, Mar 10, 2022 at 3:10 AM Alex fxmbsw7 Ratchev <fxmbsw7@gmail.com>
> wrote:
>
>> fix
>>
>> minsize() { < <( LC_ALL=C find "${@:2}"  -printf %p\\0%s\\0\\0 ) gawk -v
>> RS=\\0\\0 -v FS=\\0 -v min=$1 'BEGIN { while ( getline <"/dev/stdin" ) if (
>> ++i && $2 <= min ) print $1 ; exit }' ; }
>>
>> On Thu, Mar 10, 2022 at 3:09 AM Alex fxmbsw7 Ratchev <fxmbsw7@gmail.com>
>> wrote:
>>
>>> filename printing :
>>>
>>> minsize() { < <( LC_ALL=C find "${@:2}"  -printf %p\\0%s\\0\\0 ) gawk -v
>>> RS=\\0\\0 -v FS=\\0 -v min=$1 'BEGIN { while ( getline <"/dev/stdin" ) if (
>>> ++i && $1 <= min ) print $1 ; exit }' ; }
>>>
>>> minsize <minsize> <find entry points>
>>>
>>> On Thu, Mar 10, 2022 at 3:03 AM Alex fxmbsw7 Ratchev <fxmbsw7@gmail.com>
>>> wrote:
>>>
>>>> lil correction, not printf 22 >22 , its printf 22 >2
>>>>
>>>> On Thu, Mar 10, 2022 at 3:02 AM Alex fxmbsw7 Ratchev <fxmbsw7@gmail.com>
>>>> wrote:
>>>>
>>>>> mkdir ttt
>>>>> cd ttt
>>>>>
>>>>> >0 ; printf 1 >1 ; printf 22 >22 ; printf 333 >3
>>>>>
>>>>> minsize() { < <( LC_ALL=C find "${@:2}" -maxdepth 0  -printf %s\\n )
>>>>> gawk -v min=$1 'BEGIN { while ( getline <"/dev/stdin" ) if ( ++i && $0 <=
>>>>> min ) print ARGV[i] ; exit }' "${@:2}" ; }
>>>>>
>>>>> minsize 2 *
>>>>>
>>>>> >>>
>>>>>
>>>>> 0
>>>>> 1
>>>>> 2
>>>>>
>>>>> On Wed, Mar 9, 2022 at 6:10 PM Peng Yu <pengyu.ut@gmail.com> wrote:
>>>>> >
>>>>> >
>>>>> https://stackoverflow.com/questions/5920333/how-can-i-check-the-size-of-a-file-using-bash
>>>>> >
>>>>> > I see things like the above that call an external program or cat all
>>>>> > the file content to check the size of a file.
>>>>> >
>>>>> > But if my goal is just to know whether the file size is greater than
>>>>> a
>>>>> > smaller (say 40). What is the most efficient way to do so in bash?
>>>>> >
>>>>> > --
>>>>> > Regards,
>>>>> > Peng
>>>>>
>>>>


reply via email to

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