Find all files with group write only permissions

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP












0















In the following example directory



$ ls -l
total 0
-rw-r--r-- 1 user testgroup 0 12 feb 12:00 file1
-rw-rw-r-- 1 user testgroup 0 12 feb 12:00 file2
-rw--w-r-- 1 user testgroup 0 12 feb 12:00 file3
-rw-r--r-- 1 user testgroup 0 12 feb 12:00 file4
-rw-rwxr-- 1 user testgroup 0 12 feb 12:00 file5


I would like to find all the files where group permissions are exactly -w-, that is 2 (only write permission).



I am using



$ bash --version
GNU bash, versione 4.4.23(1)-release (amd64-portbld-freebsd12.0)


on FreeBSD 12. It is not GNU find.



My attempt was with



$ find . -perm -g+w
./file2
./file3
./file5


but this returns all the files having at least group write permissions; I would like to list instead the files whose group is only permitted to write. How to accomplish this?










share|improve this question
























  • have you tried g=w?

    – ctrl-alt-delor
    Feb 12 at 12:13












  • @ctrl-alt-delor Yes, the result is empty. No files found.

    – BowPark
    Feb 12 at 12:23















0















In the following example directory



$ ls -l
total 0
-rw-r--r-- 1 user testgroup 0 12 feb 12:00 file1
-rw-rw-r-- 1 user testgroup 0 12 feb 12:00 file2
-rw--w-r-- 1 user testgroup 0 12 feb 12:00 file3
-rw-r--r-- 1 user testgroup 0 12 feb 12:00 file4
-rw-rwxr-- 1 user testgroup 0 12 feb 12:00 file5


I would like to find all the files where group permissions are exactly -w-, that is 2 (only write permission).



I am using



$ bash --version
GNU bash, versione 4.4.23(1)-release (amd64-portbld-freebsd12.0)


on FreeBSD 12. It is not GNU find.



My attempt was with



$ find . -perm -g+w
./file2
./file3
./file5


but this returns all the files having at least group write permissions; I would like to list instead the files whose group is only permitted to write. How to accomplish this?










share|improve this question
























  • have you tried g=w?

    – ctrl-alt-delor
    Feb 12 at 12:13












  • @ctrl-alt-delor Yes, the result is empty. No files found.

    – BowPark
    Feb 12 at 12:23













0












0








0








In the following example directory



$ ls -l
total 0
-rw-r--r-- 1 user testgroup 0 12 feb 12:00 file1
-rw-rw-r-- 1 user testgroup 0 12 feb 12:00 file2
-rw--w-r-- 1 user testgroup 0 12 feb 12:00 file3
-rw-r--r-- 1 user testgroup 0 12 feb 12:00 file4
-rw-rwxr-- 1 user testgroup 0 12 feb 12:00 file5


I would like to find all the files where group permissions are exactly -w-, that is 2 (only write permission).



I am using



$ bash --version
GNU bash, versione 4.4.23(1)-release (amd64-portbld-freebsd12.0)


on FreeBSD 12. It is not GNU find.



My attempt was with



$ find . -perm -g+w
./file2
./file3
./file5


but this returns all the files having at least group write permissions; I would like to list instead the files whose group is only permitted to write. How to accomplish this?










share|improve this question
















In the following example directory



$ ls -l
total 0
-rw-r--r-- 1 user testgroup 0 12 feb 12:00 file1
-rw-rw-r-- 1 user testgroup 0 12 feb 12:00 file2
-rw--w-r-- 1 user testgroup 0 12 feb 12:00 file3
-rw-r--r-- 1 user testgroup 0 12 feb 12:00 file4
-rw-rwxr-- 1 user testgroup 0 12 feb 12:00 file5


I would like to find all the files where group permissions are exactly -w-, that is 2 (only write permission).



I am using



$ bash --version
GNU bash, versione 4.4.23(1)-release (amd64-portbld-freebsd12.0)


on FreeBSD 12. It is not GNU find.



My attempt was with



$ find . -perm -g+w
./file2
./file3
./file5


but this returns all the files having at least group write permissions; I would like to list instead the files whose group is only permitted to write. How to accomplish this?







files permissions find freebsd






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Feb 12 at 12:12









ctrl-alt-delor

11.9k42260




11.9k42260










asked Feb 12 at 11:36









BowParkBowPark

1,58882645




1,58882645












  • have you tried g=w?

    – ctrl-alt-delor
    Feb 12 at 12:13












  • @ctrl-alt-delor Yes, the result is empty. No files found.

    – BowPark
    Feb 12 at 12:23

















  • have you tried g=w?

    – ctrl-alt-delor
    Feb 12 at 12:13












  • @ctrl-alt-delor Yes, the result is empty. No files found.

    – BowPark
    Feb 12 at 12:23
















have you tried g=w?

– ctrl-alt-delor
Feb 12 at 12:13






have you tried g=w?

– ctrl-alt-delor
Feb 12 at 12:13














@ctrl-alt-delor Yes, the result is empty. No files found.

– BowPark
Feb 12 at 12:23





@ctrl-alt-delor Yes, the result is empty. No files found.

– BowPark
Feb 12 at 12:23










1 Answer
1






active

oldest

votes


















2














You can add more conditions to exclude files with other permission bits set.



find . -perm -g+w ! -perm -g+r ! -perm -g+x


or (as proposed in steeldriver's comment)



find . -perm -g+w ! -perm /g+rx


Example:



$ ls -l file*
-rw-r--r-- 1 bodo bodo 0 Feb 12 12:50 file1
-rw-rw-r-- 1 bodo bodo 0 Feb 12 12:50 file2
-rw--w-r-- 1 bodo bodo 0 Feb 12 12:50 file3
-rw--wxr-- 1 bodo bodo 0 Feb 12 12:50 file4
-rw-rwxr-- 1 bodo bodo 0 Feb 12 12:50 file5
$ find . -perm -g+w ! -perm -g+r ! -perm -g+x
./file3
$
$ find . -perm -g+w ! -perm /g+rx
./file3
$





share|improve this answer

























  • +1, it works! It can surely be used this way. But I wonder if there is a direct way: it would be weird if there wasn't.

    – BowPark
    Feb 12 at 12:27











  • You can make it slightly more compact in GNU find using the /perm form e.g. -perm -g+w ! -perm /g+rx

    – steeldriver
    Feb 12 at 13:50










Your Answer








StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f500149%2ffind-all-files-with-group-write-only-permissions%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









2














You can add more conditions to exclude files with other permission bits set.



find . -perm -g+w ! -perm -g+r ! -perm -g+x


or (as proposed in steeldriver's comment)



find . -perm -g+w ! -perm /g+rx


Example:



$ ls -l file*
-rw-r--r-- 1 bodo bodo 0 Feb 12 12:50 file1
-rw-rw-r-- 1 bodo bodo 0 Feb 12 12:50 file2
-rw--w-r-- 1 bodo bodo 0 Feb 12 12:50 file3
-rw--wxr-- 1 bodo bodo 0 Feb 12 12:50 file4
-rw-rwxr-- 1 bodo bodo 0 Feb 12 12:50 file5
$ find . -perm -g+w ! -perm -g+r ! -perm -g+x
./file3
$
$ find . -perm -g+w ! -perm /g+rx
./file3
$





share|improve this answer

























  • +1, it works! It can surely be used this way. But I wonder if there is a direct way: it would be weird if there wasn't.

    – BowPark
    Feb 12 at 12:27











  • You can make it slightly more compact in GNU find using the /perm form e.g. -perm -g+w ! -perm /g+rx

    – steeldriver
    Feb 12 at 13:50















2














You can add more conditions to exclude files with other permission bits set.



find . -perm -g+w ! -perm -g+r ! -perm -g+x


or (as proposed in steeldriver's comment)



find . -perm -g+w ! -perm /g+rx


Example:



$ ls -l file*
-rw-r--r-- 1 bodo bodo 0 Feb 12 12:50 file1
-rw-rw-r-- 1 bodo bodo 0 Feb 12 12:50 file2
-rw--w-r-- 1 bodo bodo 0 Feb 12 12:50 file3
-rw--wxr-- 1 bodo bodo 0 Feb 12 12:50 file4
-rw-rwxr-- 1 bodo bodo 0 Feb 12 12:50 file5
$ find . -perm -g+w ! -perm -g+r ! -perm -g+x
./file3
$
$ find . -perm -g+w ! -perm /g+rx
./file3
$





share|improve this answer

























  • +1, it works! It can surely be used this way. But I wonder if there is a direct way: it would be weird if there wasn't.

    – BowPark
    Feb 12 at 12:27











  • You can make it slightly more compact in GNU find using the /perm form e.g. -perm -g+w ! -perm /g+rx

    – steeldriver
    Feb 12 at 13:50













2












2








2







You can add more conditions to exclude files with other permission bits set.



find . -perm -g+w ! -perm -g+r ! -perm -g+x


or (as proposed in steeldriver's comment)



find . -perm -g+w ! -perm /g+rx


Example:



$ ls -l file*
-rw-r--r-- 1 bodo bodo 0 Feb 12 12:50 file1
-rw-rw-r-- 1 bodo bodo 0 Feb 12 12:50 file2
-rw--w-r-- 1 bodo bodo 0 Feb 12 12:50 file3
-rw--wxr-- 1 bodo bodo 0 Feb 12 12:50 file4
-rw-rwxr-- 1 bodo bodo 0 Feb 12 12:50 file5
$ find . -perm -g+w ! -perm -g+r ! -perm -g+x
./file3
$
$ find . -perm -g+w ! -perm /g+rx
./file3
$





share|improve this answer















You can add more conditions to exclude files with other permission bits set.



find . -perm -g+w ! -perm -g+r ! -perm -g+x


or (as proposed in steeldriver's comment)



find . -perm -g+w ! -perm /g+rx


Example:



$ ls -l file*
-rw-r--r-- 1 bodo bodo 0 Feb 12 12:50 file1
-rw-rw-r-- 1 bodo bodo 0 Feb 12 12:50 file2
-rw--w-r-- 1 bodo bodo 0 Feb 12 12:50 file3
-rw--wxr-- 1 bodo bodo 0 Feb 12 12:50 file4
-rw-rwxr-- 1 bodo bodo 0 Feb 12 12:50 file5
$ find . -perm -g+w ! -perm -g+r ! -perm -g+x
./file3
$
$ find . -perm -g+w ! -perm /g+rx
./file3
$






share|improve this answer














share|improve this answer



share|improve this answer








edited Feb 12 at 13:55

























answered Feb 12 at 11:54









BodoBodo

2,048416




2,048416












  • +1, it works! It can surely be used this way. But I wonder if there is a direct way: it would be weird if there wasn't.

    – BowPark
    Feb 12 at 12:27











  • You can make it slightly more compact in GNU find using the /perm form e.g. -perm -g+w ! -perm /g+rx

    – steeldriver
    Feb 12 at 13:50

















  • +1, it works! It can surely be used this way. But I wonder if there is a direct way: it would be weird if there wasn't.

    – BowPark
    Feb 12 at 12:27











  • You can make it slightly more compact in GNU find using the /perm form e.g. -perm -g+w ! -perm /g+rx

    – steeldriver
    Feb 12 at 13:50
















+1, it works! It can surely be used this way. But I wonder if there is a direct way: it would be weird if there wasn't.

– BowPark
Feb 12 at 12:27





+1, it works! It can surely be used this way. But I wonder if there is a direct way: it would be weird if there wasn't.

– BowPark
Feb 12 at 12:27













You can make it slightly more compact in GNU find using the /perm form e.g. -perm -g+w ! -perm /g+rx

– steeldriver
Feb 12 at 13:50





You can make it slightly more compact in GNU find using the /perm form e.g. -perm -g+w ! -perm /g+rx

– steeldriver
Feb 12 at 13:50

















draft saved

draft discarded
















































Thanks for contributing an answer to Unix & Linux Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f500149%2ffind-all-files-with-group-write-only-permissions%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown






Popular posts from this blog

Peggy Mitchell

Palaiologos

The Forum (Inglewood, California)