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

On Wed, Mar 9, 2022 at 11:10 AM Peng Yu <pengyu.ut@gmail.com> wrote:
> 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?

Perhaps convince Chet to make the stat loadable part of builtins, rather
than just an example builtin?

  $ enable -f ./stat.so stat
  $ help stat
  stat: stat [-lL] [-A aname] file
      Load an associative array with file status information.

      Take a filename and load the status information returned by a
      stat(2) call on that file into the associative array specified
      by the -A option.  The default array name is STAT.  If the -L
      option is supplied, stat does not resolve symbolic links and
      reports information about the link itself.  The -l option results
      in longer-form listings for some of the fields. The exit status is 0
      unless the stat fails or assigning the array is unsuccessful.
  $ stat -A motd /etc/motd
  $ declare -p motd
  declare -A motd=([type]="-" [gid]="0" [atime]="1646838713"
[mtime]="1515886594" [ctime]="1546663212" [device]="64768"
[blocks]="8" [perms]="0644" [inode]="8388721" [blksize]="4096"
[uid]="0" [size]="286" [nlink]="1" [link]="/etc/motd" [rdev]="0"
[name]="/etc/motd" )



reply via email to

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