Solved How to find files larger than x?

find(1)

Code:
     -size n[ckMGTP]
	     True if the file's	size, rounded up, in 512-byte blocks is	n.  If
	     n is followed by a	c, then	the primary is true if the file's size
	     is	n bytes	(characters).  Similarly if n is followed by a scale
	     indicator then 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)
 
You can use something like
Code:
find /usr/home -type f | xargs stat -f '%N %z' | awk '{ if ($2 > 10000000) { print $1;}}'
 
-size might not do what you want, as it'll be looking for an exact size, not larger than.
 
-size might not do what you want, as it'll be looking for an exact size, not larger than.
Yes, I had done my due diligence and concluded that -size is not the desired function. Web searching only produced results for Linux, where -size accepts operators, including greater-than.
 
You can use something like
Code:
find /usr/home -type f | xargs stat -f '%N %z' | awk '{ if ($2 > 10000000) { print $1;}}'
Code:
$ find /usr/home -type f | xargs stat -f '%N %z' | awk '{ if ($2 > 10000000) { print $1;}}'
find: /usr/home/user1/.ssh: Permission denied
xargs: unterminated quote
Seems to be a problem in the xargs bit.
 
Code:
zpaqfranz dir /usr/home /s -minsize 10000000
 
Seems to be a problem in the xargs bit.

Probably the wrong kind of quote problem.

No. The command was run from a user account (judging by the $ prompt). One user cannot read the ~/.ssh directory (and some of the files under it, like your private keys) of another user. Hence the "permission denied". That 'error' then propagated to xargs(1) which also produces an error message based on the erroneous input it received from the find(1) command.
 
The error message would go out on stderr, not stdout, so won't impact xargs (reading from its stdin). Try
Code:
mkdir foo; chmod 0 foo
find . -type f | xargs stat -f '%N %z' | awk '{ if ($2 > 10000000) { print $1;}}'

[Edit] The error message from xargs indicates that one of the input files has a single quote in it. Try
Code:
touch a\'b
find . -type f | xargs stat -f '%N %z' | awk '{ if ($2 > 10000000) { print $1;}}'
If it was the wrong kind of quote the shell would complain not xargs.
 
Back
Top