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 themFile Permissions and umaskchmod 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
How to avoid theft of potentially patentable IP when trying to obtain a Ph.D?
Why didn't Britain or any other European power colonise Abyssinia/Ethiopia before 1936?
Is it legal to use cash pulled from a credit card to pay the monthly payment on that credit card?
Pointwise convergence of uniformly continuous functions to zero, but not uniformly
Is it legal for private citizens to "impound" e-scooters?
Why do all my history books divide Chinese history after the Han dynasty?
Can anyone give a concrete example to illustrate what is an uniform prior?
How to kill my goat in Goat Simulator
Use cases for M-0 & C-0?
If Trump gets impeached, how long would Pence be president?
How did Mysterio have these drones?
How can I say in Russian "they cannot make the tournament attractive by itself"?
Is a topological space considered to be a class in set theory?
Send a single HTML email from Thunderbird, overriding the default "plain text" setting
What are the different qualities of the intervals?
Seaborn style plot of pandas dataframe
Why do planes need a roll motion?
Word for showing a small part of something briefly to hint to its existence or beauty without fully uncovering it
Why can't my huge trees be chopped down?
What do you call a flexible diving platform?
If my pay period is split between 2 calendar years, which tax year do I file them in?
Suggestions for protecting jeans from saddle clamp bolt
What is the most efficient way to write 'for' loops in Matlab?
Why is drive/partition number still used?
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 themFile Permissions and umaskchmod 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
28.1k6 gold badges84 silver badges116 bronze badges
28.1k6 gold badges84 silver badges116 bronze badges
asked Jul 17 at 17:25
BlueDogRanchBlueDogRanch
1236 bronze badges
1236 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/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%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
28.1k6 gold badges84 silver badges116 bronze badges
28.1k6 gold badges84 silver badges116 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