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:03:30 +0100

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]