Using wildcards for -group or -user with find commandFind a file where name starts with a capital letterFind files that end with numberPrint file name extension using -exec in findBatch Renaming ScriptFind files with group permissions more restrictive than owner permissionsCommand find and tar in scriptRegex not matching file using `find` despite being validFind and Replace with Sed, not a regular fileFind command - file path with white spaceBash array with folder paths and wildcards
How many days for hunting?
Why didn't Thatcher give Hong Kong to Taiwan?
Planet that’s 90% water or more?
Generate points for smooth movement between two given points
If I have an accident, should I file a claim with my car insurance company?
Unknown,AppDomain 66 (master.sys[runtime].65) is Marked for Unload Due to Memory Pressure
Is Levitate supposed to basically disable a melee based enemy?
To which airspace does the border of two adjacent airspaces belong to?
How does speed affect lift?
Why do old games use flashing as means of showing damage?
Do I need to get a noble in order to win Splendor?
When is it legal to castle moving the rook first?
How could a planet have one hemisphere way warmer than the other without the planet being tidally locked?
Go for an isolated pawn
Question about derivation of kinematics equations
Is there any reason to change the ISO manually?
My boss says "This will help us better view the utilization of your services." Does this mean my job is ending in this organisation?
Is mathematics truth?
Does this bike use hydraulic brakes?
Why did the VIC-II and SID use 6 µm technology in the era of 3 µm and 1.5 µm?
slowest crash on the Moon?
Why did the Joi advertisement trigger K?
Were the women of Travancore, India, taxed for covering their breasts by breast size?
Which is the best password hashing algorithm in .NET Core?
Using wildcards for -group or -user with find command
Find a file where name starts with a capital letterFind files that end with numberPrint file name extension using -exec in findBatch Renaming ScriptFind files with group permissions more restrictive than owner permissionsCommand find and tar in scriptRegex not matching file using `find` despite being validFind and Replace with Sed, not a regular fileFind command - file path with white spaceBash array with folder paths and wildcards
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I'm trying to find owners of files on the system that all start with a specific name, for example
[unu@here findtest]$ find . -ls
17295583 0 drwxrwxr-x 2 unu unu 74 Mar 28 03:14 .
17295584 0 -rw-rw-r-- 1 br_asd1 br_asd1 0 Mar 28 03:13 ./test1
17295585 0 -rw-rw-r-- 1 br_asd2 br_asd2 0 Mar 28 03:13 ./test2
17295586 0 -rw-rw-r-- 1 unu unu 0 Mar 28 03:13 ./test33
17295587 0 -rw-rw-r-- 1 br_bfg1 br_bfg1 0 Mar 28 03:14 ./test11
17295588 0 -rw-rw-r-- 1 unu unu 0 Mar 28 03:14 ./test22
I need find to only get files owned by users whose name starts with "br_".
So what I tried was
[unu@here findtest]$ find . -user "br_*" -ls
find: ‘br_*’ is not the name of a known user
Now a method I found that works is using awk, but I have certain problems with this method and it's not really usable for what I'm trying:
[unu@here findtest]$ find . -ls|awk 'if ($5 ~ "br_"'
17295584 0 -rw-rw-r-- 1 br_asd1 br_asd1 0 Mar 28 03:13 ./test1
17295585 0 -rw-rw-r-- 1 br_asd2 br_asd2 0 Mar 28 03:13 ./test2
17295587 0 -rw-rw-r-- 1 br_bfg1 br_bfg1 0 Mar 28 03:14 ./test11
Is there a way to add wildcards to the -user
or -group
options of find?
bash find wildcards
migrated from stackoverflow.com Mar 28 at 3:29
This question came from our site for professional and enthusiast programmers.
add a comment |
I'm trying to find owners of files on the system that all start with a specific name, for example
[unu@here findtest]$ find . -ls
17295583 0 drwxrwxr-x 2 unu unu 74 Mar 28 03:14 .
17295584 0 -rw-rw-r-- 1 br_asd1 br_asd1 0 Mar 28 03:13 ./test1
17295585 0 -rw-rw-r-- 1 br_asd2 br_asd2 0 Mar 28 03:13 ./test2
17295586 0 -rw-rw-r-- 1 unu unu 0 Mar 28 03:13 ./test33
17295587 0 -rw-rw-r-- 1 br_bfg1 br_bfg1 0 Mar 28 03:14 ./test11
17295588 0 -rw-rw-r-- 1 unu unu 0 Mar 28 03:14 ./test22
I need find to only get files owned by users whose name starts with "br_".
So what I tried was
[unu@here findtest]$ find . -user "br_*" -ls
find: ‘br_*’ is not the name of a known user
Now a method I found that works is using awk, but I have certain problems with this method and it's not really usable for what I'm trying:
[unu@here findtest]$ find . -ls|awk 'if ($5 ~ "br_"'
17295584 0 -rw-rw-r-- 1 br_asd1 br_asd1 0 Mar 28 03:13 ./test1
17295585 0 -rw-rw-r-- 1 br_asd2 br_asd2 0 Mar 28 03:13 ./test2
17295587 0 -rw-rw-r-- 1 br_bfg1 br_bfg1 0 Mar 28 03:14 ./test11
Is there a way to add wildcards to the -user
or -group
options of find?
bash find wildcards
migrated from stackoverflow.com Mar 28 at 3:29
This question came from our site for professional and enthusiast programmers.
Withgetent passwd
get a list of users which matchbr_.*
and build a list like:--user br_asd1 --user br_asd2 --user br_bfg1
forfind
command.
– Cyrus
Mar 28 at 3:33
GNUfind
does not have options to pass wildcards for-user
and-group
fields. One way would be to use GNU coreutilsstat
and use the%U
quantifier to get the owner name. Do something likefor file in *; do [ -f "$file" ] || continue; owner=$(stat -c '%U' "$file"); if [[ "$owner" =~ ^br.* ]]; then echo "$file"; fi; done
– Inian
Mar 28 at 3:52
add a comment |
I'm trying to find owners of files on the system that all start with a specific name, for example
[unu@here findtest]$ find . -ls
17295583 0 drwxrwxr-x 2 unu unu 74 Mar 28 03:14 .
17295584 0 -rw-rw-r-- 1 br_asd1 br_asd1 0 Mar 28 03:13 ./test1
17295585 0 -rw-rw-r-- 1 br_asd2 br_asd2 0 Mar 28 03:13 ./test2
17295586 0 -rw-rw-r-- 1 unu unu 0 Mar 28 03:13 ./test33
17295587 0 -rw-rw-r-- 1 br_bfg1 br_bfg1 0 Mar 28 03:14 ./test11
17295588 0 -rw-rw-r-- 1 unu unu 0 Mar 28 03:14 ./test22
I need find to only get files owned by users whose name starts with "br_".
So what I tried was
[unu@here findtest]$ find . -user "br_*" -ls
find: ‘br_*’ is not the name of a known user
Now a method I found that works is using awk, but I have certain problems with this method and it's not really usable for what I'm trying:
[unu@here findtest]$ find . -ls|awk 'if ($5 ~ "br_"'
17295584 0 -rw-rw-r-- 1 br_asd1 br_asd1 0 Mar 28 03:13 ./test1
17295585 0 -rw-rw-r-- 1 br_asd2 br_asd2 0 Mar 28 03:13 ./test2
17295587 0 -rw-rw-r-- 1 br_bfg1 br_bfg1 0 Mar 28 03:14 ./test11
Is there a way to add wildcards to the -user
or -group
options of find?
bash find wildcards
I'm trying to find owners of files on the system that all start with a specific name, for example
[unu@here findtest]$ find . -ls
17295583 0 drwxrwxr-x 2 unu unu 74 Mar 28 03:14 .
17295584 0 -rw-rw-r-- 1 br_asd1 br_asd1 0 Mar 28 03:13 ./test1
17295585 0 -rw-rw-r-- 1 br_asd2 br_asd2 0 Mar 28 03:13 ./test2
17295586 0 -rw-rw-r-- 1 unu unu 0 Mar 28 03:13 ./test33
17295587 0 -rw-rw-r-- 1 br_bfg1 br_bfg1 0 Mar 28 03:14 ./test11
17295588 0 -rw-rw-r-- 1 unu unu 0 Mar 28 03:14 ./test22
I need find to only get files owned by users whose name starts with "br_".
So what I tried was
[unu@here findtest]$ find . -user "br_*" -ls
find: ‘br_*’ is not the name of a known user
Now a method I found that works is using awk, but I have certain problems with this method and it's not really usable for what I'm trying:
[unu@here findtest]$ find . -ls|awk 'if ($5 ~ "br_"'
17295584 0 -rw-rw-r-- 1 br_asd1 br_asd1 0 Mar 28 03:13 ./test1
17295585 0 -rw-rw-r-- 1 br_asd2 br_asd2 0 Mar 28 03:13 ./test2
17295587 0 -rw-rw-r-- 1 br_bfg1 br_bfg1 0 Mar 28 03:14 ./test11
Is there a way to add wildcards to the -user
or -group
options of find?
bash find wildcards
bash find wildcards
edited Mar 28 at 4:07
Prvt_Yadv
3,9113 gold badges17 silver badges34 bronze badges
3,9113 gold badges17 silver badges34 bronze badges
asked Mar 28 at 3:21
Lhakryma DL
migrated from stackoverflow.com Mar 28 at 3:29
This question came from our site for professional and enthusiast programmers.
migrated from stackoverflow.com Mar 28 at 3:29
This question came from our site for professional and enthusiast programmers.
migrated from stackoverflow.com Mar 28 at 3:29
This question came from our site for professional and enthusiast programmers.
Withgetent passwd
get a list of users which matchbr_.*
and build a list like:--user br_asd1 --user br_asd2 --user br_bfg1
forfind
command.
– Cyrus
Mar 28 at 3:33
GNUfind
does not have options to pass wildcards for-user
and-group
fields. One way would be to use GNU coreutilsstat
and use the%U
quantifier to get the owner name. Do something likefor file in *; do [ -f "$file" ] || continue; owner=$(stat -c '%U' "$file"); if [[ "$owner" =~ ^br.* ]]; then echo "$file"; fi; done
– Inian
Mar 28 at 3:52
add a comment |
Withgetent passwd
get a list of users which matchbr_.*
and build a list like:--user br_asd1 --user br_asd2 --user br_bfg1
forfind
command.
– Cyrus
Mar 28 at 3:33
GNUfind
does not have options to pass wildcards for-user
and-group
fields. One way would be to use GNU coreutilsstat
and use the%U
quantifier to get the owner name. Do something likefor file in *; do [ -f "$file" ] || continue; owner=$(stat -c '%U' "$file"); if [[ "$owner" =~ ^br.* ]]; then echo "$file"; fi; done
– Inian
Mar 28 at 3:52
With
getent passwd
get a list of users which match br_.*
and build a list like: --user br_asd1 --user br_asd2 --user br_bfg1
for find
command.– Cyrus
Mar 28 at 3:33
With
getent passwd
get a list of users which match br_.*
and build a list like: --user br_asd1 --user br_asd2 --user br_bfg1
for find
command.– Cyrus
Mar 28 at 3:33
GNU
find
does not have options to pass wildcards for -user
and -group
fields. One way would be to use GNU coreutils stat
and use the %U
quantifier to get the owner name. Do something like for file in *; do [ -f "$file" ] || continue; owner=$(stat -c '%U' "$file"); if [[ "$owner" =~ ^br.* ]]; then echo "$file"; fi; done
– Inian
Mar 28 at 3:52
GNU
find
does not have options to pass wildcards for -user
and -group
fields. One way would be to use GNU coreutils stat
and use the %U
quantifier to get the owner name. Do something like for file in *; do [ -f "$file" ] || continue; owner=$(stat -c '%U' "$file"); if [[ "$owner" =~ ^br.* ]]; then echo "$file"; fi; done
– Inian
Mar 28 at 3:52
add a comment |
2 Answers
2
active
oldest
votes
If you're writing for bash
you can use an array to hold the set of users and another array to generate the corresponding syntax for find
to match those users:
#!/bin/bash
# The beginning of the userids we need to match
match=br
# Find the matching set of users
users=($(
getent passwd |
awk -F: -vm="$match" 'BEGIN re = "^" m $1 ~ re print $1'
))
# Build the list of users ("find ( -user XX -o -user YY -o user ZZ ) ...")
finds=()
for user in "$users[@]"
do
finds+=('-o' '-user' "$user")
done
[[ $#finds[@] -gt 0 ]] && finds=('(' "$finds[@]:1" ')')
# Execute the find command with the set of users
find . "$finds[@]" -ls
As ever, you can prefix the find
command with something like echo
to see what would be executed. (Or you could run with bash -x
to enable line-by-line debug reporting.)
Instead of the test in each iteration of that loop, you could just use"$finds[@]:1"
when callingfind
to ignore that first-o
in the list.
– Kusalananda♦
Mar 28 at 8:46
add a comment |
If all you need is just a listing, I would go for a good old grep
over find
’s output. It would be slower, but much less typing.
At the very basic you might try this, for your example case:
find -printf '%u %pn' | egrep '^br_'
This gives you the list of files owned by users br_*
, shown with username and filename on each line.
You might then expand the output by fiddling the -printf
format string.
For instance, to make it resemble more an ls
output:
find -printf '%-8.8u %-8.8g %M %8s %t %pn' | egrep '^br_'
The important thing to keep the command line as short as possible is to place the username at the very beginning, so that the egrep
’s part can be kept short like that.
To see all that you can specify in the format string, go here, then search for -printf format
.
Be careful though that if your files have newlines in their names then this solution might have problems in showing them.
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%2f509121%2fusing-wildcards-for-group-or-user-with-find-command%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
If you're writing for bash
you can use an array to hold the set of users and another array to generate the corresponding syntax for find
to match those users:
#!/bin/bash
# The beginning of the userids we need to match
match=br
# Find the matching set of users
users=($(
getent passwd |
awk -F: -vm="$match" 'BEGIN re = "^" m $1 ~ re print $1'
))
# Build the list of users ("find ( -user XX -o -user YY -o user ZZ ) ...")
finds=()
for user in "$users[@]"
do
finds+=('-o' '-user' "$user")
done
[[ $#finds[@] -gt 0 ]] && finds=('(' "$finds[@]:1" ')')
# Execute the find command with the set of users
find . "$finds[@]" -ls
As ever, you can prefix the find
command with something like echo
to see what would be executed. (Or you could run with bash -x
to enable line-by-line debug reporting.)
Instead of the test in each iteration of that loop, you could just use"$finds[@]:1"
when callingfind
to ignore that first-o
in the list.
– Kusalananda♦
Mar 28 at 8:46
add a comment |
If you're writing for bash
you can use an array to hold the set of users and another array to generate the corresponding syntax for find
to match those users:
#!/bin/bash
# The beginning of the userids we need to match
match=br
# Find the matching set of users
users=($(
getent passwd |
awk -F: -vm="$match" 'BEGIN re = "^" m $1 ~ re print $1'
))
# Build the list of users ("find ( -user XX -o -user YY -o user ZZ ) ...")
finds=()
for user in "$users[@]"
do
finds+=('-o' '-user' "$user")
done
[[ $#finds[@] -gt 0 ]] && finds=('(' "$finds[@]:1" ')')
# Execute the find command with the set of users
find . "$finds[@]" -ls
As ever, you can prefix the find
command with something like echo
to see what would be executed. (Or you could run with bash -x
to enable line-by-line debug reporting.)
Instead of the test in each iteration of that loop, you could just use"$finds[@]:1"
when callingfind
to ignore that first-o
in the list.
– Kusalananda♦
Mar 28 at 8:46
add a comment |
If you're writing for bash
you can use an array to hold the set of users and another array to generate the corresponding syntax for find
to match those users:
#!/bin/bash
# The beginning of the userids we need to match
match=br
# Find the matching set of users
users=($(
getent passwd |
awk -F: -vm="$match" 'BEGIN re = "^" m $1 ~ re print $1'
))
# Build the list of users ("find ( -user XX -o -user YY -o user ZZ ) ...")
finds=()
for user in "$users[@]"
do
finds+=('-o' '-user' "$user")
done
[[ $#finds[@] -gt 0 ]] && finds=('(' "$finds[@]:1" ')')
# Execute the find command with the set of users
find . "$finds[@]" -ls
As ever, you can prefix the find
command with something like echo
to see what would be executed. (Or you could run with bash -x
to enable line-by-line debug reporting.)
If you're writing for bash
you can use an array to hold the set of users and another array to generate the corresponding syntax for find
to match those users:
#!/bin/bash
# The beginning of the userids we need to match
match=br
# Find the matching set of users
users=($(
getent passwd |
awk -F: -vm="$match" 'BEGIN re = "^" m $1 ~ re print $1'
))
# Build the list of users ("find ( -user XX -o -user YY -o user ZZ ) ...")
finds=()
for user in "$users[@]"
do
finds+=('-o' '-user' "$user")
done
[[ $#finds[@] -gt 0 ]] && finds=('(' "$finds[@]:1" ')')
# Execute the find command with the set of users
find . "$finds[@]" -ls
As ever, you can prefix the find
command with something like echo
to see what would be executed. (Or you could run with bash -x
to enable line-by-line debug reporting.)
edited Mar 28 at 9:03
answered Mar 28 at 8:29
roaimaroaima
49.4k7 gold badges66 silver badges133 bronze badges
49.4k7 gold badges66 silver badges133 bronze badges
Instead of the test in each iteration of that loop, you could just use"$finds[@]:1"
when callingfind
to ignore that first-o
in the list.
– Kusalananda♦
Mar 28 at 8:46
add a comment |
Instead of the test in each iteration of that loop, you could just use"$finds[@]:1"
when callingfind
to ignore that first-o
in the list.
– Kusalananda♦
Mar 28 at 8:46
Instead of the test in each iteration of that loop, you could just use
"$finds[@]:1"
when calling find
to ignore that first -o
in the list.– Kusalananda♦
Mar 28 at 8:46
Instead of the test in each iteration of that loop, you could just use
"$finds[@]:1"
when calling find
to ignore that first -o
in the list.– Kusalananda♦
Mar 28 at 8:46
add a comment |
If all you need is just a listing, I would go for a good old grep
over find
’s output. It would be slower, but much less typing.
At the very basic you might try this, for your example case:
find -printf '%u %pn' | egrep '^br_'
This gives you the list of files owned by users br_*
, shown with username and filename on each line.
You might then expand the output by fiddling the -printf
format string.
For instance, to make it resemble more an ls
output:
find -printf '%-8.8u %-8.8g %M %8s %t %pn' | egrep '^br_'
The important thing to keep the command line as short as possible is to place the username at the very beginning, so that the egrep
’s part can be kept short like that.
To see all that you can specify in the format string, go here, then search for -printf format
.
Be careful though that if your files have newlines in their names then this solution might have problems in showing them.
add a comment |
If all you need is just a listing, I would go for a good old grep
over find
’s output. It would be slower, but much less typing.
At the very basic you might try this, for your example case:
find -printf '%u %pn' | egrep '^br_'
This gives you the list of files owned by users br_*
, shown with username and filename on each line.
You might then expand the output by fiddling the -printf
format string.
For instance, to make it resemble more an ls
output:
find -printf '%-8.8u %-8.8g %M %8s %t %pn' | egrep '^br_'
The important thing to keep the command line as short as possible is to place the username at the very beginning, so that the egrep
’s part can be kept short like that.
To see all that you can specify in the format string, go here, then search for -printf format
.
Be careful though that if your files have newlines in their names then this solution might have problems in showing them.
add a comment |
If all you need is just a listing, I would go for a good old grep
over find
’s output. It would be slower, but much less typing.
At the very basic you might try this, for your example case:
find -printf '%u %pn' | egrep '^br_'
This gives you the list of files owned by users br_*
, shown with username and filename on each line.
You might then expand the output by fiddling the -printf
format string.
For instance, to make it resemble more an ls
output:
find -printf '%-8.8u %-8.8g %M %8s %t %pn' | egrep '^br_'
The important thing to keep the command line as short as possible is to place the username at the very beginning, so that the egrep
’s part can be kept short like that.
To see all that you can specify in the format string, go here, then search for -printf format
.
Be careful though that if your files have newlines in their names then this solution might have problems in showing them.
If all you need is just a listing, I would go for a good old grep
over find
’s output. It would be slower, but much less typing.
At the very basic you might try this, for your example case:
find -printf '%u %pn' | egrep '^br_'
This gives you the list of files owned by users br_*
, shown with username and filename on each line.
You might then expand the output by fiddling the -printf
format string.
For instance, to make it resemble more an ls
output:
find -printf '%-8.8u %-8.8g %M %8s %t %pn' | egrep '^br_'
The important thing to keep the command line as short as possible is to place the username at the very beginning, so that the egrep
’s part can be kept short like that.
To see all that you can specify in the format string, go here, then search for -printf format
.
Be careful though that if your files have newlines in their names then this solution might have problems in showing them.
answered Mar 29 at 0:13
LL3LL3
2,1772 silver badges14 bronze badges
2,1772 silver badges14 bronze badges
add a comment |
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%2f509121%2fusing-wildcards-for-group-or-user-with-find-command%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
With
getent passwd
get a list of users which matchbr_.*
and build a list like:--user br_asd1 --user br_asd2 --user br_bfg1
forfind
command.– Cyrus
Mar 28 at 3:33
GNU
find
does not have options to pass wildcards for-user
and-group
fields. One way would be to use GNU coreutilsstat
and use the%U
quantifier to get the owner name. Do something likefor file in *; do [ -f "$file" ] || continue; owner=$(stat -c '%U' "$file"); if [[ "$owner" =~ ^br.* ]]; then echo "$file"; fi; done
– Inian
Mar 28 at 3:52