“find” exclude by fstype strange behavior

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
2
down vote

favorite












I try to have "find" command exclude "/proc" filesystem.
I would prefer a portable solution to be able to use it on non GNU based hosts (oldest AIX for instance, where "find" do not have the "-path" option)



Here's what I've tried (on a Linux host) and a partial filtered output:




$ find / ! -fstype proc >/dev/null
find: `/proc/9475/task/9535/fdinfo/7': No such file or directory
find: `/proc/10856': No such file or directory
find: `/proc/10856': No such file or directory
find: `/proc/10858': No such file or directory
find: `/proc/10858': No such file or directory
find: `/proc/15650': No such file or directory
find: `/proc/15650': No such file or directory
find: `/proc/15654': No such file or directory
find: `/proc/15654': No such file or directory
find: `/proc/15656': No such file or directory
find: `/proc/15656': No such file or directory
find: `/proc/15657': No such file or directory
find: `/proc/15657': No such file or directory
find: `/proc/15663': No such file or directory
etc ....


I don't understand why "find" keep walking inside the "/proc" file system despite of the "! -fstype proc" switch?










share|improve this question







New contributor




Gilles Pion is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.























    up vote
    2
    down vote

    favorite












    I try to have "find" command exclude "/proc" filesystem.
    I would prefer a portable solution to be able to use it on non GNU based hosts (oldest AIX for instance, where "find" do not have the "-path" option)



    Here's what I've tried (on a Linux host) and a partial filtered output:




    $ find / ! -fstype proc >/dev/null
    find: `/proc/9475/task/9535/fdinfo/7': No such file or directory
    find: `/proc/10856': No such file or directory
    find: `/proc/10856': No such file or directory
    find: `/proc/10858': No such file or directory
    find: `/proc/10858': No such file or directory
    find: `/proc/15650': No such file or directory
    find: `/proc/15650': No such file or directory
    find: `/proc/15654': No such file or directory
    find: `/proc/15654': No such file or directory
    find: `/proc/15656': No such file or directory
    find: `/proc/15656': No such file or directory
    find: `/proc/15657': No such file or directory
    find: `/proc/15657': No such file or directory
    find: `/proc/15663': No such file or directory
    etc ....


    I don't understand why "find" keep walking inside the "/proc" file system despite of the "! -fstype proc" switch?










    share|improve this question







    New contributor




    Gilles Pion is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.





















      up vote
      2
      down vote

      favorite









      up vote
      2
      down vote

      favorite











      I try to have "find" command exclude "/proc" filesystem.
      I would prefer a portable solution to be able to use it on non GNU based hosts (oldest AIX for instance, where "find" do not have the "-path" option)



      Here's what I've tried (on a Linux host) and a partial filtered output:




      $ find / ! -fstype proc >/dev/null
      find: `/proc/9475/task/9535/fdinfo/7': No such file or directory
      find: `/proc/10856': No such file or directory
      find: `/proc/10856': No such file or directory
      find: `/proc/10858': No such file or directory
      find: `/proc/10858': No such file or directory
      find: `/proc/15650': No such file or directory
      find: `/proc/15650': No such file or directory
      find: `/proc/15654': No such file or directory
      find: `/proc/15654': No such file or directory
      find: `/proc/15656': No such file or directory
      find: `/proc/15656': No such file or directory
      find: `/proc/15657': No such file or directory
      find: `/proc/15657': No such file or directory
      find: `/proc/15663': No such file or directory
      etc ....


      I don't understand why "find" keep walking inside the "/proc" file system despite of the "! -fstype proc" switch?










      share|improve this question







      New contributor




      Gilles Pion is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.











      I try to have "find" command exclude "/proc" filesystem.
      I would prefer a portable solution to be able to use it on non GNU based hosts (oldest AIX for instance, where "find" do not have the "-path" option)



      Here's what I've tried (on a Linux host) and a partial filtered output:




      $ find / ! -fstype proc >/dev/null
      find: `/proc/9475/task/9535/fdinfo/7': No such file or directory
      find: `/proc/10856': No such file or directory
      find: `/proc/10856': No such file or directory
      find: `/proc/10858': No such file or directory
      find: `/proc/10858': No such file or directory
      find: `/proc/15650': No such file or directory
      find: `/proc/15650': No such file or directory
      find: `/proc/15654': No such file or directory
      find: `/proc/15654': No such file or directory
      find: `/proc/15656': No such file or directory
      find: `/proc/15656': No such file or directory
      find: `/proc/15657': No such file or directory
      find: `/proc/15657': No such file or directory
      find: `/proc/15663': No such file or directory
      etc ....


      I don't understand why "find" keep walking inside the "/proc" file system despite of the "! -fstype proc" switch?







      filesystems find proc






      share|improve this question







      New contributor




      Gilles Pion is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.











      share|improve this question







      New contributor




      Gilles Pion is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      share|improve this question




      share|improve this question






      New contributor




      Gilles Pion is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      asked 2 hours ago









      Gilles Pion

      111




      111




      New contributor




      Gilles Pion is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.





      New contributor





      Gilles Pion is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






      Gilles Pion is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.




















          2 Answers
          2






          active

          oldest

          votes

















          up vote
          3
          down vote













          The -fstype directive tells find not to return any results that are on that filesystem type. That, however, doesn't mean that it won't look at the proc filesystem. It simply means that it won't return files found there, but it still needs to go through it in case it finds a file there whose fstype isn't proc. For instance, on my Arch, I find:



          $ find /proc ! -fstype proc -printf '%p %Fn' 2>/dev/null 
          /proc/sys/fs/binfmt_misc binfmt_misc
          /proc/sys/fs/binfmt_misc/CLR binfmt_misc
          /proc/sys/fs/binfmt_misc/register binfmt_misc
          /proc/sys/fs/binfmt_misc/status binfmt_misc


          Those are 4 files in /proc whose fstype is binfmt_misc.



          So, with this in mind, note that your question only shows error messages. None of those files have actually been returned by find, so it would seem to be behaving as expected.






          share|improve this answer




















          • instead of "won't return files found there" maybe "won't return files of type proc that are found there" ?
            – Jeff Schaller
            13 mins ago

















          up vote
          2
          down vote













          As terdon explained, find will still enter the /proc directory, but it will not return any pathnames from that filesystem type.



          To remove any search path as soon as the proc filesystem type is detected, use



          find / -fstype proc -prune -o -print


          However, since you're wanting to do this on an old find, the -fstype option may not be available. If -path (a standard option of find) is also not available, then it begins to be a bit difficult to come with suggestions as the implementation is clearly not POSIX compliant.



          One option could be to use -xdev which would cause find to stay strictly in the same filesystem as the starting path. You would then have to run one find for each filesystem that you want to examine. There could also be an option called -x (as on BSD systems) which acts like -xdev.



          If that too is not possible, then you may have to resort to using -type d -name proc -prune to remove all directories that are called proc.






          share|improve this answer






















            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',
            convertImagesToLinks: false,
            noModals: false,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: "",
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );






            Gilles Pion is a new contributor. Be nice, and check out our Code of Conduct.









             

            draft saved


            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f471611%2ffind-exclude-by-fstype-strange-behavior%23new-answer', 'question_page');

            );

            Post as a guest






























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes








            up vote
            3
            down vote













            The -fstype directive tells find not to return any results that are on that filesystem type. That, however, doesn't mean that it won't look at the proc filesystem. It simply means that it won't return files found there, but it still needs to go through it in case it finds a file there whose fstype isn't proc. For instance, on my Arch, I find:



            $ find /proc ! -fstype proc -printf '%p %Fn' 2>/dev/null 
            /proc/sys/fs/binfmt_misc binfmt_misc
            /proc/sys/fs/binfmt_misc/CLR binfmt_misc
            /proc/sys/fs/binfmt_misc/register binfmt_misc
            /proc/sys/fs/binfmt_misc/status binfmt_misc


            Those are 4 files in /proc whose fstype is binfmt_misc.



            So, with this in mind, note that your question only shows error messages. None of those files have actually been returned by find, so it would seem to be behaving as expected.






            share|improve this answer




















            • instead of "won't return files found there" maybe "won't return files of type proc that are found there" ?
              – Jeff Schaller
              13 mins ago














            up vote
            3
            down vote













            The -fstype directive tells find not to return any results that are on that filesystem type. That, however, doesn't mean that it won't look at the proc filesystem. It simply means that it won't return files found there, but it still needs to go through it in case it finds a file there whose fstype isn't proc. For instance, on my Arch, I find:



            $ find /proc ! -fstype proc -printf '%p %Fn' 2>/dev/null 
            /proc/sys/fs/binfmt_misc binfmt_misc
            /proc/sys/fs/binfmt_misc/CLR binfmt_misc
            /proc/sys/fs/binfmt_misc/register binfmt_misc
            /proc/sys/fs/binfmt_misc/status binfmt_misc


            Those are 4 files in /proc whose fstype is binfmt_misc.



            So, with this in mind, note that your question only shows error messages. None of those files have actually been returned by find, so it would seem to be behaving as expected.






            share|improve this answer




















            • instead of "won't return files found there" maybe "won't return files of type proc that are found there" ?
              – Jeff Schaller
              13 mins ago












            up vote
            3
            down vote










            up vote
            3
            down vote









            The -fstype directive tells find not to return any results that are on that filesystem type. That, however, doesn't mean that it won't look at the proc filesystem. It simply means that it won't return files found there, but it still needs to go through it in case it finds a file there whose fstype isn't proc. For instance, on my Arch, I find:



            $ find /proc ! -fstype proc -printf '%p %Fn' 2>/dev/null 
            /proc/sys/fs/binfmt_misc binfmt_misc
            /proc/sys/fs/binfmt_misc/CLR binfmt_misc
            /proc/sys/fs/binfmt_misc/register binfmt_misc
            /proc/sys/fs/binfmt_misc/status binfmt_misc


            Those are 4 files in /proc whose fstype is binfmt_misc.



            So, with this in mind, note that your question only shows error messages. None of those files have actually been returned by find, so it would seem to be behaving as expected.






            share|improve this answer












            The -fstype directive tells find not to return any results that are on that filesystem type. That, however, doesn't mean that it won't look at the proc filesystem. It simply means that it won't return files found there, but it still needs to go through it in case it finds a file there whose fstype isn't proc. For instance, on my Arch, I find:



            $ find /proc ! -fstype proc -printf '%p %Fn' 2>/dev/null 
            /proc/sys/fs/binfmt_misc binfmt_misc
            /proc/sys/fs/binfmt_misc/CLR binfmt_misc
            /proc/sys/fs/binfmt_misc/register binfmt_misc
            /proc/sys/fs/binfmt_misc/status binfmt_misc


            Those are 4 files in /proc whose fstype is binfmt_misc.



            So, with this in mind, note that your question only shows error messages. None of those files have actually been returned by find, so it would seem to be behaving as expected.







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered 2 hours ago









            terdon♦

            123k28233407




            123k28233407











            • instead of "won't return files found there" maybe "won't return files of type proc that are found there" ?
              – Jeff Schaller
              13 mins ago
















            • instead of "won't return files found there" maybe "won't return files of type proc that are found there" ?
              – Jeff Schaller
              13 mins ago















            instead of "won't return files found there" maybe "won't return files of type proc that are found there" ?
            – Jeff Schaller
            13 mins ago




            instead of "won't return files found there" maybe "won't return files of type proc that are found there" ?
            – Jeff Schaller
            13 mins ago












            up vote
            2
            down vote













            As terdon explained, find will still enter the /proc directory, but it will not return any pathnames from that filesystem type.



            To remove any search path as soon as the proc filesystem type is detected, use



            find / -fstype proc -prune -o -print


            However, since you're wanting to do this on an old find, the -fstype option may not be available. If -path (a standard option of find) is also not available, then it begins to be a bit difficult to come with suggestions as the implementation is clearly not POSIX compliant.



            One option could be to use -xdev which would cause find to stay strictly in the same filesystem as the starting path. You would then have to run one find for each filesystem that you want to examine. There could also be an option called -x (as on BSD systems) which acts like -xdev.



            If that too is not possible, then you may have to resort to using -type d -name proc -prune to remove all directories that are called proc.






            share|improve this answer


























              up vote
              2
              down vote













              As terdon explained, find will still enter the /proc directory, but it will not return any pathnames from that filesystem type.



              To remove any search path as soon as the proc filesystem type is detected, use



              find / -fstype proc -prune -o -print


              However, since you're wanting to do this on an old find, the -fstype option may not be available. If -path (a standard option of find) is also not available, then it begins to be a bit difficult to come with suggestions as the implementation is clearly not POSIX compliant.



              One option could be to use -xdev which would cause find to stay strictly in the same filesystem as the starting path. You would then have to run one find for each filesystem that you want to examine. There could also be an option called -x (as on BSD systems) which acts like -xdev.



              If that too is not possible, then you may have to resort to using -type d -name proc -prune to remove all directories that are called proc.






              share|improve this answer
























                up vote
                2
                down vote










                up vote
                2
                down vote









                As terdon explained, find will still enter the /proc directory, but it will not return any pathnames from that filesystem type.



                To remove any search path as soon as the proc filesystem type is detected, use



                find / -fstype proc -prune -o -print


                However, since you're wanting to do this on an old find, the -fstype option may not be available. If -path (a standard option of find) is also not available, then it begins to be a bit difficult to come with suggestions as the implementation is clearly not POSIX compliant.



                One option could be to use -xdev which would cause find to stay strictly in the same filesystem as the starting path. You would then have to run one find for each filesystem that you want to examine. There could also be an option called -x (as on BSD systems) which acts like -xdev.



                If that too is not possible, then you may have to resort to using -type d -name proc -prune to remove all directories that are called proc.






                share|improve this answer














                As terdon explained, find will still enter the /proc directory, but it will not return any pathnames from that filesystem type.



                To remove any search path as soon as the proc filesystem type is detected, use



                find / -fstype proc -prune -o -print


                However, since you're wanting to do this on an old find, the -fstype option may not be available. If -path (a standard option of find) is also not available, then it begins to be a bit difficult to come with suggestions as the implementation is clearly not POSIX compliant.



                One option could be to use -xdev which would cause find to stay strictly in the same filesystem as the starting path. You would then have to run one find for each filesystem that you want to examine. There could also be an option called -x (as on BSD systems) which acts like -xdev.



                If that too is not possible, then you may have to resort to using -type d -name proc -prune to remove all directories that are called proc.







                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited 51 mins ago

























                answered 58 mins ago









                Kusalananda

                107k14209331




                107k14209331




















                    Gilles Pion is a new contributor. Be nice, and check out our Code of Conduct.









                     

                    draft saved


                    draft discarded


















                    Gilles Pion is a new contributor. Be nice, and check out our Code of Conduct.












                    Gilles Pion is a new contributor. Be nice, and check out our Code of Conduct.











                    Gilles Pion is a new contributor. Be nice, and check out our Code of Conduct.













                     


                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f471611%2ffind-exclude-by-fstype-strange-behavior%23new-answer', 'question_page');

                    );

                    Post as a guest













































































                    Comments

                    Popular posts from this blog

                    What does second last employer means? [closed]

                    Installing NextGIS Connect into QGIS 3?

                    One-line joke