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;









4

















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?










share|improve this question




























  • Could you consider allowing permission change on all files, and then reinstating the permissions for those two files?

    – pierrely
    Jul 20 at 6:04

















4

















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?










share|improve this question




























  • Could you consider allowing permission change on all files, and then reinstating the permissions for those two files?

    – pierrely
    Jul 20 at 6:04













4












4








4


2






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?










share|improve this question

















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






share|improve this question
















share|improve this question













share|improve this question




share|improve this question








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

















  • 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










1 Answer
1






active

oldest

votes


















7


















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





share|improve this answer





























    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
    );



    );














    draft saved

    draft discarded
















    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









    7


















    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





    share|improve this answer
































      7


















      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





      share|improve this answer






























        7














        7










        7









        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





        share|improve this answer
















        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






        share|improve this answer















        share|improve this answer




        share|improve this answer








        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































            draft saved

            draft discarded















































            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.




            draft saved


            draft discarded














            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





















































            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

            Distance measures on a map of a game The 2019 Stack Overflow Developer Survey Results Are Inmin distance in a graphShortest distance path on contour plotHow to plot a tilted map?Finding points outside of a diskDelaunay link distanceAnnulus from GeoDisks: drawing a ring on a mapNegative Correlation DistanceFind distance along a path (GPS coordinates)Finding position at given distance in a GeoPathMathematics behind distance estimation using camera

            How to get a smooth, uniform ParametricPlot of a 2D Region?How to plot a complicated Region?How to exclude a region from ParametricPlotHow discretize a region placing vertices on a specific non-uniform gridHow to transform a Plot or a ParametricPlot into a RegionHow can I get a smooth plot of a bounded region?Smooth ParametricPlot3D with RegionFunction?Smooth border of a region ParametricPlotSmooth region boundarySmooth region plot from list of pointsGet minimum y of a certain x in a region

            Genealogie vun de Merowenger Vum Merowech bis zum Chilperich I. | Navigatiounsmenü