Find all files with group write only permissions

Clash Royale CLAN TAG#URR8PPP
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
add a comment |
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
have you triedg=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
add a comment |
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
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
files permissions find freebsd
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 triedg=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
add a comment |
have you triedg=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
add a comment |
1 Answer
1
active
oldest
votes
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
$
+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 GNUfindusing the/permform e.g.-perm -g+w ! -perm /g+rx
– steeldriver
Feb 12 at 13:50
add a comment |
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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
$
+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 GNUfindusing the/permform e.g.-perm -g+w ! -perm /g+rx
– steeldriver
Feb 12 at 13:50
add a comment |
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
$
+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 GNUfindusing the/permform e.g.-perm -g+w ! -perm /g+rx
– steeldriver
Feb 12 at 13:50
add a comment |
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
$
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
$
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 GNUfindusing the/permform e.g.-perm -g+w ! -perm /g+rx
– steeldriver
Feb 12 at 13:50
add a comment |
+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 GNUfindusing the/permform 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
add a comment |
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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