To find the size of some group of files

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





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








1















I was trying to find out the total size of all files which are owned by a particular user.



While trying so, i get different sizes when executing different commands.



Which command is correct to find out the total size of all files owned by the particular user?



$ find . -type f -user silviya|ls -lh|head -1 
total 68K
$ find . -type f -user agalya|wc -c
284
$ find . -type f -user agalya|du -sk
120 .


What is the reason for this variation?










share|improve this question






























    1















    I was trying to find out the total size of all files which are owned by a particular user.



    While trying so, i get different sizes when executing different commands.



    Which command is correct to find out the total size of all files owned by the particular user?



    $ find . -type f -user silviya|ls -lh|head -1 
    total 68K
    $ find . -type f -user agalya|wc -c
    284
    $ find . -type f -user agalya|du -sk
    120 .


    What is the reason for this variation?










    share|improve this question


























      1












      1








      1








      I was trying to find out the total size of all files which are owned by a particular user.



      While trying so, i get different sizes when executing different commands.



      Which command is correct to find out the total size of all files owned by the particular user?



      $ find . -type f -user silviya|ls -lh|head -1 
      total 68K
      $ find . -type f -user agalya|wc -c
      284
      $ find . -type f -user agalya|du -sk
      120 .


      What is the reason for this variation?










      share|improve this question
















      I was trying to find out the total size of all files which are owned by a particular user.



      While trying so, i get different sizes when executing different commands.



      Which command is correct to find out the total size of all files owned by the particular user?



      $ find . -type f -user silviya|ls -lh|head -1 
      total 68K
      $ find . -type f -user agalya|wc -c
      284
      $ find . -type f -user agalya|du -sk
      120 .


      What is the reason for this variation?







      shell files find size






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 9 at 13:24









      Rui F Ribeiro

      41.9k1483142




      41.9k1483142










      asked Feb 19 '16 at 13:18









      SilviyaSilviya

      114




      114




















          2 Answers
          2






          active

          oldest

          votes


















          5














          In:



          find . -type f -user silviya|ls -lh|head -1 


          you're piping the output of find to ls, but ls doesn't read its input. It takes the list of files to list as arguments. In the absence of arguments like here, it lists the non-hidden files in the current directory. So here, you get the disk usage of all the non-hidden files (of any type) in the current directory (with the size of a given file counted for each of its hard links).



          In:



          find . -type f -user agalya|wc -c


          You're counting the number of bytes in the output of find, so that's the size of the file paths (and newline delimiters), not their disk usage nor file size.



          In:



          find . -type f -user agalya|du -sk


          Like ls, du takes the file list as arguments, not from its input. So here, you get the disk usage of all the files and directories in the current directory (recursively).



          To get the disk usage of all regular files owned by agalya, with GNU utilities, you'd do:



          find . -type f -user agalya -print0 | du -hc --files0-from=- | tail -n 1


          --files0-from tells du (GNU du only) to take the file list from standard input (represented by - here). -c gives the cumulative size (note that hard links of a same file are counted only once).



          To get the file apparent size as opposed to disk usage, add the --apparent-size option to du (again, GNU specific). Add the -l option (also GNU-specific) to count hard links several times.






          share|improve this answer






























            -1














            Command #1 gives the total size of the "useful" bytes of the files, of their contents.



            Command #3 gives used disk space to hold the files. Disks are divided into blocks (often 4 kB long) that can't be shared by several files. So a file of any size between 1 and 4096 B will used 4 kB of disk space e.g. [This is simplified. On some FS types like ext, very small files can be stored into the file table itself, using no data blocks at all.]



            Command #2 just counts the number of characters of the file names. (Size of the output of the find command.)






            share|improve this answer


















            • 1





              That's missing the most important point, command 1 and 3 apply to the current directory, not the output of find. Also, the total line in ls -l output gives disk usage like du, not useful bytes.

              – Stéphane Chazelas
              Feb 19 '16 at 13:54











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



            );













            draft saved

            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f264357%2fto-find-the-size-of-some-group-of-files%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









            5














            In:



            find . -type f -user silviya|ls -lh|head -1 


            you're piping the output of find to ls, but ls doesn't read its input. It takes the list of files to list as arguments. In the absence of arguments like here, it lists the non-hidden files in the current directory. So here, you get the disk usage of all the non-hidden files (of any type) in the current directory (with the size of a given file counted for each of its hard links).



            In:



            find . -type f -user agalya|wc -c


            You're counting the number of bytes in the output of find, so that's the size of the file paths (and newline delimiters), not their disk usage nor file size.



            In:



            find . -type f -user agalya|du -sk


            Like ls, du takes the file list as arguments, not from its input. So here, you get the disk usage of all the files and directories in the current directory (recursively).



            To get the disk usage of all regular files owned by agalya, with GNU utilities, you'd do:



            find . -type f -user agalya -print0 | du -hc --files0-from=- | tail -n 1


            --files0-from tells du (GNU du only) to take the file list from standard input (represented by - here). -c gives the cumulative size (note that hard links of a same file are counted only once).



            To get the file apparent size as opposed to disk usage, add the --apparent-size option to du (again, GNU specific). Add the -l option (also GNU-specific) to count hard links several times.






            share|improve this answer



























              5














              In:



              find . -type f -user silviya|ls -lh|head -1 


              you're piping the output of find to ls, but ls doesn't read its input. It takes the list of files to list as arguments. In the absence of arguments like here, it lists the non-hidden files in the current directory. So here, you get the disk usage of all the non-hidden files (of any type) in the current directory (with the size of a given file counted for each of its hard links).



              In:



              find . -type f -user agalya|wc -c


              You're counting the number of bytes in the output of find, so that's the size of the file paths (and newline delimiters), not their disk usage nor file size.



              In:



              find . -type f -user agalya|du -sk


              Like ls, du takes the file list as arguments, not from its input. So here, you get the disk usage of all the files and directories in the current directory (recursively).



              To get the disk usage of all regular files owned by agalya, with GNU utilities, you'd do:



              find . -type f -user agalya -print0 | du -hc --files0-from=- | tail -n 1


              --files0-from tells du (GNU du only) to take the file list from standard input (represented by - here). -c gives the cumulative size (note that hard links of a same file are counted only once).



              To get the file apparent size as opposed to disk usage, add the --apparent-size option to du (again, GNU specific). Add the -l option (also GNU-specific) to count hard links several times.






              share|improve this answer

























                5












                5








                5







                In:



                find . -type f -user silviya|ls -lh|head -1 


                you're piping the output of find to ls, but ls doesn't read its input. It takes the list of files to list as arguments. In the absence of arguments like here, it lists the non-hidden files in the current directory. So here, you get the disk usage of all the non-hidden files (of any type) in the current directory (with the size of a given file counted for each of its hard links).



                In:



                find . -type f -user agalya|wc -c


                You're counting the number of bytes in the output of find, so that's the size of the file paths (and newline delimiters), not their disk usage nor file size.



                In:



                find . -type f -user agalya|du -sk


                Like ls, du takes the file list as arguments, not from its input. So here, you get the disk usage of all the files and directories in the current directory (recursively).



                To get the disk usage of all regular files owned by agalya, with GNU utilities, you'd do:



                find . -type f -user agalya -print0 | du -hc --files0-from=- | tail -n 1


                --files0-from tells du (GNU du only) to take the file list from standard input (represented by - here). -c gives the cumulative size (note that hard links of a same file are counted only once).



                To get the file apparent size as opposed to disk usage, add the --apparent-size option to du (again, GNU specific). Add the -l option (also GNU-specific) to count hard links several times.






                share|improve this answer













                In:



                find . -type f -user silviya|ls -lh|head -1 


                you're piping the output of find to ls, but ls doesn't read its input. It takes the list of files to list as arguments. In the absence of arguments like here, it lists the non-hidden files in the current directory. So here, you get the disk usage of all the non-hidden files (of any type) in the current directory (with the size of a given file counted for each of its hard links).



                In:



                find . -type f -user agalya|wc -c


                You're counting the number of bytes in the output of find, so that's the size of the file paths (and newline delimiters), not their disk usage nor file size.



                In:



                find . -type f -user agalya|du -sk


                Like ls, du takes the file list as arguments, not from its input. So here, you get the disk usage of all the files and directories in the current directory (recursively).



                To get the disk usage of all regular files owned by agalya, with GNU utilities, you'd do:



                find . -type f -user agalya -print0 | du -hc --files0-from=- | tail -n 1


                --files0-from tells du (GNU du only) to take the file list from standard input (represented by - here). -c gives the cumulative size (note that hard links of a same file are counted only once).



                To get the file apparent size as opposed to disk usage, add the --apparent-size option to du (again, GNU specific). Add the -l option (also GNU-specific) to count hard links several times.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Feb 19 '16 at 13:40









                Stéphane ChazelasStéphane Chazelas

                313k57592948




                313k57592948























                    -1














                    Command #1 gives the total size of the "useful" bytes of the files, of their contents.



                    Command #3 gives used disk space to hold the files. Disks are divided into blocks (often 4 kB long) that can't be shared by several files. So a file of any size between 1 and 4096 B will used 4 kB of disk space e.g. [This is simplified. On some FS types like ext, very small files can be stored into the file table itself, using no data blocks at all.]



                    Command #2 just counts the number of characters of the file names. (Size of the output of the find command.)






                    share|improve this answer


















                    • 1





                      That's missing the most important point, command 1 and 3 apply to the current directory, not the output of find. Also, the total line in ls -l output gives disk usage like du, not useful bytes.

                      – Stéphane Chazelas
                      Feb 19 '16 at 13:54















                    -1














                    Command #1 gives the total size of the "useful" bytes of the files, of their contents.



                    Command #3 gives used disk space to hold the files. Disks are divided into blocks (often 4 kB long) that can't be shared by several files. So a file of any size between 1 and 4096 B will used 4 kB of disk space e.g. [This is simplified. On some FS types like ext, very small files can be stored into the file table itself, using no data blocks at all.]



                    Command #2 just counts the number of characters of the file names. (Size of the output of the find command.)






                    share|improve this answer


















                    • 1





                      That's missing the most important point, command 1 and 3 apply to the current directory, not the output of find. Also, the total line in ls -l output gives disk usage like du, not useful bytes.

                      – Stéphane Chazelas
                      Feb 19 '16 at 13:54













                    -1












                    -1








                    -1







                    Command #1 gives the total size of the "useful" bytes of the files, of their contents.



                    Command #3 gives used disk space to hold the files. Disks are divided into blocks (often 4 kB long) that can't be shared by several files. So a file of any size between 1 and 4096 B will used 4 kB of disk space e.g. [This is simplified. On some FS types like ext, very small files can be stored into the file table itself, using no data blocks at all.]



                    Command #2 just counts the number of characters of the file names. (Size of the output of the find command.)






                    share|improve this answer













                    Command #1 gives the total size of the "useful" bytes of the files, of their contents.



                    Command #3 gives used disk space to hold the files. Disks are divided into blocks (often 4 kB long) that can't be shared by several files. So a file of any size between 1 and 4096 B will used 4 kB of disk space e.g. [This is simplified. On some FS types like ext, very small files can be stored into the file table itself, using no data blocks at all.]



                    Command #2 just counts the number of characters of the file names. (Size of the output of the find command.)







                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered Feb 19 '16 at 13:39









                    L. LevrelL. Levrel

                    1,249417




                    1,249417







                    • 1





                      That's missing the most important point, command 1 and 3 apply to the current directory, not the output of find. Also, the total line in ls -l output gives disk usage like du, not useful bytes.

                      – Stéphane Chazelas
                      Feb 19 '16 at 13:54












                    • 1





                      That's missing the most important point, command 1 and 3 apply to the current directory, not the output of find. Also, the total line in ls -l output gives disk usage like du, not useful bytes.

                      – Stéphane Chazelas
                      Feb 19 '16 at 13:54







                    1




                    1





                    That's missing the most important point, command 1 and 3 apply to the current directory, not the output of find. Also, the total line in ls -l output gives disk usage like du, not useful bytes.

                    – Stéphane Chazelas
                    Feb 19 '16 at 13:54





                    That's missing the most important point, command 1 and 3 apply to the current directory, not the output of find. Also, the total line in ls -l output gives disk usage like du, not useful bytes.

                    – Stéphane Chazelas
                    Feb 19 '16 at 13:54

















                    draft saved

                    draft discarded
















































                    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.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f264357%2fto-find-the-size-of-some-group-of-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

                    How to check contact read email or not when send email to Individual?

                    Bahrain

                    Postfix configuration issue with fips on centos 7; mailgun relay