Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I searched for big files using this command on HP Unix:

find . -type f -size +100000000c -exec ls -lrt {} \;

The result came out somthing like this:

-rw-rw-rw-   1 qa1wrk32   test       169263642 Oct 27 12:28 ./rgs/test/qa1wrk32/DB/Dmp/intrefbl01_20111027_Backup_for_qa1ref32_CNSTRNO.dmp.gz
-rw-rw-rw-   1 qa1wrk32   test       173779937 Oct 24 16:33 ./rgs/test/qa1wrk32/DB/Dmp/qa1ref32_20111024_Backup_before_Refresh.dmp.gz
-rw-rw-rw-   1 qa1wrk32   test       105020030 Oct 31 09:53 ./rgs/test/qa1wrk32/DB/Dmp/qa1app32_20111031_R112_Before_CopyBan_from_INT01_to_ENV32_for_LISA_CNSTRNO.dmp.gz
find: cannot open ./rgs/test/maes32/master/.ssh
find: cannot open ./rgs/test/qa1oln32/.ssh
find: cannot open ./rgs/test/qa1oln32/local_tlg/bin/.adm
find: cannot search ./rgs/test/qa1wrk91/mail

I don't want the lines of output where find fails to search or open or anything else. Is there a way to filter them out? Better yet, can I make find search for files with some set of permissions?

share|improve this question
well I tried this but it didnt work find . -type f -size +100000000c -exec ls -lrt {} \; | grep -v cannot – munish Nov 4 '11 at 7:05
up vote 9 down vote accepted

find prints the errors to stderr. If you just want to ignore them, the simplest thing to do is:

find ... 2> /dev/null

find also has the -perm option to filter based on permissions.

share|improve this answer

You can tell find to search for files with particular permissions, but it's not quite what you need here. You need to tell find not to explore directories that you don't have permission to traverse. It's actually easy to tell find not to descend into a directory — it's the -prune primary — but there's no easy way to match directories that you don't have permission to traverse. In GNU find, you can write -readable -executable, but standard find has no such option (nor does HP-UX find).

You can reconstruct your access rights from permissions, but it's painful. And on systems that have ACLs (which HP-UX does), you need to take these into account as well.

find . -type d \
       \! \( -user $(id -u) -perm -u+rx -o \
             \( -group $(id -G | sed 's/ / -o -group /g') \) -perm -g+rx -o \
             -perm -a+rx \) -prune -o \
     -type f -size +100000000c -exec …

In practice, unless this is a mission-critical script, you probably want to ignore the errors from find. (And if it's a mission-critical script, write it in some other language that allows better filtering of error conditions, like Perl or Python.)

share|improve this answer
Thanks, I like your answer because i like you mentioning that what i can't do when it comes to a certain *nix(like HP-unix), and suitable option for doing this. good explanation.Thanks – munish Nov 5 '11 at 1:03

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.