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: Dennis Williamson
Subject: Re: Check if file size greater than a small number?
Date: Wed, 9 Mar 2022 11:42:11 -0600

On Wed, Mar 9, 2022 at 11:10 AM 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
>
>
size=41
filename=testfile
read -n "$size" < "$filename"
if ((${#REPLY} >= size)) ...

-- 
Visit serverfault.com to get your system administration questions answered.


reply via email to

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