I'm trying to find files with size larger than "x" , ex: 32 bytes
But what I found in ls --help was only ls -S , that just sort by size and not satisfied my demand
I'm new to Linux , I've tried Google but I don't know what keywords should I use to find answer , could somebody give me advice , thank you !
Try to use the power of find utility.
Find files greater than 32 bytes:
find -size +32c
Of course you could also ask for files smaller than 32 bytes:
find -size -32c
And files with exact 32 bytes:
find -size 32c
For files with 32 bytes or more:
find -size 32c -o -size +32c
Or not smaller than 32 bytes (the same as above, but written another way):
find ! -size -32c
And files between 32 and 64 bytes:
find -size +32c -size -64c
And you can also apply other common suffixes:
find -size +32k -size -64M
Try this:
find . -size +32c -ls
You can change 32 for the size you want. In this case, I used your example.
Explanation: Use unix command find Using -size oprator
The find utility recursively descends the directory tree for each path listed, evaluating an expression (composed of the 'primaries' and 'operands') in terms of each file in the tree.
Solution: According to the documentation
-size n[ckMGTP]
True if the file's size, rounded up, in 512-byte blocks is n. If n is fol-
lowed by a c, than the primary is true if the file's size is n bytes (charac-
ters). Similarly if n is followed by a scale indicator than the file's size
is compared to n scaled as:
k kilobytes (1024 bytes)
M megabytes (1024 kilobytes)
G gigabytes (1024 megabytes)
T terabytes (1024 gigabytes)
P petabytes (1024 terabytes)
Usage: perform find operation with -size flag and threshold measurement arguments: more than(+)/less than(-), number(n) and measurement type (k/M/G/T/P).
Formula: find <path> -size [+/-]<Number><Measurement>
Examples:
1.Greater Than - Find all files in my current directory (.) that greater than 500 kilobyte
find . -size +500k
2.Less Than - Find all files in my current directory (.) that less than 100 megabyte.
find . -size -100M
3.Range - Find specific file (test) in my current directory (.) that greater than 500 kilobyte less than 100 megabyte (500k-1000k)
find . -name "test" -size +500k -size -100M
4.Complex Range with Regex Find all .mkv files in all filesystem (root /) that are greater than 1 gigabyte and created this month, and present info of them.
find / -name "*.mkv" -size +1G -type f -ctime -4w | xargs ls -la