Use chown -R while excluding one or two filesWhat is the purpose of shopt -s extglobchanging permissions of `nyccrash.txt': Operation not permittedchown recursively changed permissionsComparing two text filesJoin two files keeping the element order of one of themchmod not working in a non super userSetting www-data and me as the owner?using link command to see how it worksComparing contents of two filescompare two lines and print unmatched words from two files
Was Senegal involved in the 1918 Russian Revolution?
Is it acceptable to mark off or comment on someone's presentation based on their non-standard English accent?
What is a good way to challenge a Warlock with the Agonizing Blast invocation?
An historical mystery : Poincaré’s silence on Lebesgue integral and measure theory?
Is it sportsmanlike to waste opponents' time by giving check at the end of the game?
How to write a bootable ISO Windows installation disk to a disk partition (and not USB flash drive)?
MS in Mathematics, having trouble finding work outside teaching algebra
What would happen to the world if all lightning stopped?
If the Feign Death spell is cast on a creature, do they register as magical if the Detect Magic spell is cast to inspect them?
In a shuttle launch, what would have happened if all three SSMEs failed during flight?
Visiting a place in Brussels where Pink Floyd recorded a video
Does using "gleich" in a question add or remove politeness?
vim: (E)dit anyway without prompting
Fermat's Last Theorem, mod n
Could the Ancient Egyptian hieroglyphs have been deciphered without the Rosetta Stone with modern tech?
How can I find all Ubuntu iso files and other images?
Does a symmetric positive definite matrix also have A = L^T * L, (L is lower triangular matrix)?
Physical interpretation of complex numbers
Is it possible to keep cat litter on balcony during winter (down to -10°C)
How to get out of the Ice Palace in Zelda A link to the Past?
Explanatory vs Non-explanatory Proofs
Why did Leia not want to tell Han about Luke being her twin brother?
Did Abraham and Noah know of each other?
Does FreeBSD contain multiple variants of basic regex?
Use chown -R while excluding one or two files
What is the purpose of shopt -s extglobchanging permissions of `nyccrash.txt': Operation not permittedchown recursively changed permissionsComparing two text filesJoin two files keeping the element order of one of themchmod not working in a non super userSetting www-data and me as the owner?using link command to see how it worksComparing contents of two filescompare two lines and print unmatched words from two files
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty
margin-bottom:0;
How can I use chown -R but exclude one or two files?
I periodically need to run
sudo chown -R www-data:www-data *
and
sudo chown -R ubuntu:ubuntu *
But I'd like to exclude one or two files from those commands as to not change the permissions of those excluded files.
How can I exclude file1.php, or both file2.txt and file3.php?
command-line chown
add a comment
|
How can I use chown -R but exclude one or two files?
I periodically need to run
sudo chown -R www-data:www-data *
and
sudo chown -R ubuntu:ubuntu *
But I'd like to exclude one or two files from those commands as to not change the permissions of those excluded files.
How can I exclude file1.php, or both file2.txt and file3.php?
command-line chown
Could you consider allowing permission change on all files, and then reinstating the permissions for those two files?
– pierrely
Jul 20 at 6:04
add a comment
|
How can I use chown -R but exclude one or two files?
I periodically need to run
sudo chown -R www-data:www-data *
and
sudo chown -R ubuntu:ubuntu *
But I'd like to exclude one or two files from those commands as to not change the permissions of those excluded files.
How can I exclude file1.php, or both file2.txt and file3.php?
command-line chown
How can I use chown -R but exclude one or two files?
I periodically need to run
sudo chown -R www-data:www-data *
and
sudo chown -R ubuntu:ubuntu *
But I'd like to exclude one or two files from those commands as to not change the permissions of those excluded files.
How can I exclude file1.php, or both file2.txt and file3.php?
command-line chown
command-line chown
edited Jul 17 at 19:09
dessert
29.5k7 gold badges88 silver badges121 bronze badges
29.5k7 gold badges88 silver badges121 bronze badges
asked Jul 17 at 17:25
BlueDogRanchBlueDogRanch
1231 silver badge6 bronze badges
1231 silver badge6 bronze badges
Could you consider allowing permission change on all files, and then reinstating the permissions for those two files?
– pierrely
Jul 20 at 6:04
add a comment
|
Could you consider allowing permission change on all files, and then reinstating the permissions for those two files?
– pierrely
Jul 20 at 6:04
Could you consider allowing permission change on all files, and then reinstating the permissions for those two files?
– pierrely
Jul 20 at 6:04
Could you consider allowing permission change on all files, and then reinstating the permissions for those two files?
– pierrely
Jul 20 at 6:04
add a comment
|
1 Answer
1
active
oldest
votes
Set bash’s extglob option with
shopt -s extglob
and use it like that to exclude these files:
sudo chown -R www-data:www-data !(file1.php)
sudo chown -R ubuntu:ubuntu !(file2.txt|file3.php)
This works with files and directories equally, but only in the current directory. If you need to exclude files in subdirectories, combine the above with the globstar option (shopt -s globstar):
sudo chown -R www-data:www-data **/!(file1.php)
This matches every file and directory except the ones called file1.php.
Example run
$ touch 1..3
$ shopt -s extglob
$ echo !(1)
2 3
$ echo !(1|2)
3
$ mkdir a
$ touch a/1..3
$ tree
.
├── 1
├── 2
├── 3
└── a
├── 1
├── 2
└── 3
$ shopt -s globstar
$ echo **/!(1|2)
3 a a/3
Further reading
man bash/EXPANSION/Pathname Expansion/Pattern Matching- What is the purpose of shopt -s extglob
- bash-hackers.org: Extended pattern language
add a comment
|
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "89"
;
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: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
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/4.0/"u003ecc by-sa 4.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%2faskubuntu.com%2fquestions%2f1159025%2fuse-chown-r-while-excluding-one-or-two-files%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
Set bash’s extglob option with
shopt -s extglob
and use it like that to exclude these files:
sudo chown -R www-data:www-data !(file1.php)
sudo chown -R ubuntu:ubuntu !(file2.txt|file3.php)
This works with files and directories equally, but only in the current directory. If you need to exclude files in subdirectories, combine the above with the globstar option (shopt -s globstar):
sudo chown -R www-data:www-data **/!(file1.php)
This matches every file and directory except the ones called file1.php.
Example run
$ touch 1..3
$ shopt -s extglob
$ echo !(1)
2 3
$ echo !(1|2)
3
$ mkdir a
$ touch a/1..3
$ tree
.
├── 1
├── 2
├── 3
└── a
├── 1
├── 2
└── 3
$ shopt -s globstar
$ echo **/!(1|2)
3 a a/3
Further reading
man bash/EXPANSION/Pathname Expansion/Pattern Matching- What is the purpose of shopt -s extglob
- bash-hackers.org: Extended pattern language
add a comment
|
Set bash’s extglob option with
shopt -s extglob
and use it like that to exclude these files:
sudo chown -R www-data:www-data !(file1.php)
sudo chown -R ubuntu:ubuntu !(file2.txt|file3.php)
This works with files and directories equally, but only in the current directory. If you need to exclude files in subdirectories, combine the above with the globstar option (shopt -s globstar):
sudo chown -R www-data:www-data **/!(file1.php)
This matches every file and directory except the ones called file1.php.
Example run
$ touch 1..3
$ shopt -s extglob
$ echo !(1)
2 3
$ echo !(1|2)
3
$ mkdir a
$ touch a/1..3
$ tree
.
├── 1
├── 2
├── 3
└── a
├── 1
├── 2
└── 3
$ shopt -s globstar
$ echo **/!(1|2)
3 a a/3
Further reading
man bash/EXPANSION/Pathname Expansion/Pattern Matching- What is the purpose of shopt -s extglob
- bash-hackers.org: Extended pattern language
add a comment
|
Set bash’s extglob option with
shopt -s extglob
and use it like that to exclude these files:
sudo chown -R www-data:www-data !(file1.php)
sudo chown -R ubuntu:ubuntu !(file2.txt|file3.php)
This works with files and directories equally, but only in the current directory. If you need to exclude files in subdirectories, combine the above with the globstar option (shopt -s globstar):
sudo chown -R www-data:www-data **/!(file1.php)
This matches every file and directory except the ones called file1.php.
Example run
$ touch 1..3
$ shopt -s extglob
$ echo !(1)
2 3
$ echo !(1|2)
3
$ mkdir a
$ touch a/1..3
$ tree
.
├── 1
├── 2
├── 3
└── a
├── 1
├── 2
└── 3
$ shopt -s globstar
$ echo **/!(1|2)
3 a a/3
Further reading
man bash/EXPANSION/Pathname Expansion/Pattern Matching- What is the purpose of shopt -s extglob
- bash-hackers.org: Extended pattern language
Set bash’s extglob option with
shopt -s extglob
and use it like that to exclude these files:
sudo chown -R www-data:www-data !(file1.php)
sudo chown -R ubuntu:ubuntu !(file2.txt|file3.php)
This works with files and directories equally, but only in the current directory. If you need to exclude files in subdirectories, combine the above with the globstar option (shopt -s globstar):
sudo chown -R www-data:www-data **/!(file1.php)
This matches every file and directory except the ones called file1.php.
Example run
$ touch 1..3
$ shopt -s extglob
$ echo !(1)
2 3
$ echo !(1|2)
3
$ mkdir a
$ touch a/1..3
$ tree
.
├── 1
├── 2
├── 3
└── a
├── 1
├── 2
└── 3
$ shopt -s globstar
$ echo **/!(1|2)
3 a a/3
Further reading
man bash/EXPANSION/Pathname Expansion/Pattern Matching- What is the purpose of shopt -s extglob
- bash-hackers.org: Extended pattern language
edited Jul 17 at 20:32
answered Jul 17 at 17:39
dessertdessert
29.5k7 gold badges88 silver badges121 bronze badges
29.5k7 gold badges88 silver badges121 bronze badges
add a comment
|
add a comment
|
Thanks for contributing an answer to Ask Ubuntu!
- 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%2faskubuntu.com%2fquestions%2f1159025%2fuse-chown-r-while-excluding-one-or-two-files%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
Could you consider allowing permission change on all files, and then reinstating the permissions for those two files?
– pierrely
Jul 20 at 6:04