-3

I would like to list all the files in ~ whose size is greater than 100 kB but without using the find command. I need to do it with stat.

1 Answers1

1

stat can't list files based on a condition, but you can combine find and stat to get them work together:

find -type f -size +100k -exec stat {} +

or to get specific outout for example files permissions:

find -type f -size +100k -exec stat -c %a {} +

Or write a script which only uses stat:

#!/bin/bash
for file in $HOME/*; do
 if [ -f "$file" ] && [[ $(stat -c %s "$file") -ge 100000 ]]; then
        echo "$file"
 fi
done
Ravexina
  • 2,638
  • 1
  • 19
  • 33