0

We're using the following hp-ux configuration:

HP-UX dxp10hxw B.11.23 U 9000/800 1446354274 unlimited-user license

And trying to run a simple find command as follows:

find . ! -type l -perm -0020 -exec ls -l {} \;

This is supposed to produce a list of all files/folders in the current directory, which have a group writable permission. However, it also lists the files which don't have a group-writable permission

We did some research and tried variations of above command like:

find . ! -type l -perm -g+w -exec ls -l {} \;
find . ! -type l -perm -g=w -exec ls -l {} \;

But nothing seem to be working. We tried googling, but not much google results for hp-ux. on hp-ux forums, the closest we could find was: http://community.hpe.com/t5/System-Administration/commnd-to-find-All-world-writable-files-in-hpux-11-0-system/td-p/3260440 but the suggestions mentioned there don't help either.

We did try finding one file at a time. For example, if there is a file temp.txt with permissions 711 and it figures in the results when we run above command. Then we modified the command to search only for that file instead of all files in the current directory and the below command

find ./temp.txt ! -type l -perm -g+w -exec ls -l {} \; 

did not yield any results. Then we tried supplying a small set of files in the folder and the list of files that was received as output was correct but as soon as the number of files increased in the folder, the results were incorrect again. So at least we realized this thing that for a big list of files (about 600 files) in a single search, find was breaking Please help!

2

The command

find . ! -type l -perm -0020 -exec ls -l {} \;

is close. But if you add the -d option to the ls command, it will work, by not telling it to list the contents of directories.

The command as given will recur through subdirectories; the question only mentions files (and folders...). You might have meant

find . -type f -perm -0020 -exec ls -l {} \;

to ignore directories entirely. The given command will list directories also which have group-writable permissions.

  • Thomas, you're the King sir!!! it worked :-) – JavaTec Mar 21 '16 at 21:48
  • 1
    -type f only includes regular files. It does exclude directories and symlinks but also all the other non-regular types of files (sockets, fifo, devices...). Use ! -type d ! -type l to exclude directories (I would still use -d though). – Stéphane Chazelas Mar 21 '16 at 22:07
2
find . ! -type l -perm -g=w -exec ls -lLd {} \;

under /tmp containing ~6000 files, the command above worked for me on HP-UX 11.11 server. Your problem is not coming from number of files. 600 files is only a drop in the sea, unless your physical memory amount is really low.

  • Hi MelBurslan, thank you, this also works :-) I wish there was option to accept two answers, since i already accepted Thomas Dickey's answer – JavaTec Mar 21 '16 at 21:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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