Find command size greater than or equalto

How do I find the files greater than or equal to a given size using find command.

find ./ -size +0k   --> Lists files greater than 0K

find ./ -size 0k --> Lists the file size equal to 0K.

I have other conditions to check, hence using find command.

Thanks in advance.

Your example is a bit odd. *All* files have a size 0 or greater.
To find files that are greater or equal than 10k you can negate it, "not smaller than 10k"

find . \! -size -10k 

This is more efficient than an or condition

find . \( -size 10k -o -size +10k \)

I have a purge script. Based on the Input parameter, the script has to find and delete the files greater than or equal to the nkb. For now, I am using the or condition as you mentioned above.

Thanks.

I have a faint memory of find 's size rounding methods being a bit strange on some systems. You might want to search these forums for the discussion of it.

Would stat give you a getter output to work with? It gives you the output in a customisable format. Using ls or the -ls flag on find can cause issues if the file has a group name with spaces, for example:-

# stat bigfile
  File: `bigfile'
  Size: 6762219520	Blocks: 13207472   IO Block: 4096   regular file
Device: fd00h/64768d	Inode: 2359475     Links: 1
Access: (0664/-rw-rw-r--)  Uid: (  500/rbatte1)   Gid: (  500/rbatte1)
Access: 2017-07-19 12:23:40.597780337 +0100
Modify: 2017-07-19 12:27:58.730711684 +0100
Change: 2017-07-19 12:28:17.474415803 +0100

It might not be neat, but if you use find to get a list of files based on whatever other criteria you have, you can then work through the list with some simple tests for file size, a bit like this:-

while read listed_file
do
   listed_file_size="$(stat -c%s${listed_file})
   if [ ${listed_file_size} -gt 10240 ]
   then
      echo "File ${listed_file} is greater than 10K at ${listed_file_size} bytes."
   fi
done < /tmp/file_list

Of course, you could substitute an input file for the output of your find command.

If you are looking for files over a certain size, then another option might be to call stat from your find with xargs, perhaps:-

find /path/to/search -type f any other options | xargs stat -c '%s %n' | sort -n

This will give you the files in size order, so once you have the first file that exceeds your limit, you can assume that all the others will too.

What is the full criteria of your search and what actions do you want to take? It would be useful to show us the output from uname -a too.

Thanks, in advance,
Robin