Adding size of files using shell script












2















I want to add and echo the sum of several files using shell script. How do I start?
I have a list of them like that:



$ stat /etc/*.conf | grep Size | cut -f4 -d' '
123
456
789
101112









share|improve this question




















  • 5





    you don't we simply use du?

    – msp9011
    Nov 21 '18 at 7:30






  • 1





    @msp9011, du will calculate also subdirectories

    – Romeo Ninov
    Nov 21 '18 at 7:39






  • 1





    @RomeoNinov here we are checking only files...du -b /etc/*.conf

    – msp9011
    Nov 21 '18 at 8:42











  • @msp9011 Not if there is a directory matching the pattern. It's unlikely but not impossible.

    – BlackJack
    Nov 21 '18 at 17:55











  • @msp9011 due to block sizes, etc, disk usage is not the same as total file size.

    – OrangeDog
    Nov 22 '18 at 11:45
















2















I want to add and echo the sum of several files using shell script. How do I start?
I have a list of them like that:



$ stat /etc/*.conf | grep Size | cut -f4 -d' '
123
456
789
101112









share|improve this question




















  • 5





    you don't we simply use du?

    – msp9011
    Nov 21 '18 at 7:30






  • 1





    @msp9011, du will calculate also subdirectories

    – Romeo Ninov
    Nov 21 '18 at 7:39






  • 1





    @RomeoNinov here we are checking only files...du -b /etc/*.conf

    – msp9011
    Nov 21 '18 at 8:42











  • @msp9011 Not if there is a directory matching the pattern. It's unlikely but not impossible.

    – BlackJack
    Nov 21 '18 at 17:55











  • @msp9011 due to block sizes, etc, disk usage is not the same as total file size.

    – OrangeDog
    Nov 22 '18 at 11:45














2












2








2








I want to add and echo the sum of several files using shell script. How do I start?
I have a list of them like that:



$ stat /etc/*.conf | grep Size | cut -f4 -d' '
123
456
789
101112









share|improve this question
















I want to add and echo the sum of several files using shell script. How do I start?
I have a list of them like that:



$ stat /etc/*.conf | grep Size | cut -f4 -d' '
123
456
789
101112






shell-script shell






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 21 '18 at 7:16









muru

1




1










asked Nov 21 '18 at 7:13









C. CristiC. Cristi

1647




1647








  • 5





    you don't we simply use du?

    – msp9011
    Nov 21 '18 at 7:30






  • 1





    @msp9011, du will calculate also subdirectories

    – Romeo Ninov
    Nov 21 '18 at 7:39






  • 1





    @RomeoNinov here we are checking only files...du -b /etc/*.conf

    – msp9011
    Nov 21 '18 at 8:42











  • @msp9011 Not if there is a directory matching the pattern. It's unlikely but not impossible.

    – BlackJack
    Nov 21 '18 at 17:55











  • @msp9011 due to block sizes, etc, disk usage is not the same as total file size.

    – OrangeDog
    Nov 22 '18 at 11:45














  • 5





    you don't we simply use du?

    – msp9011
    Nov 21 '18 at 7:30






  • 1





    @msp9011, du will calculate also subdirectories

    – Romeo Ninov
    Nov 21 '18 at 7:39






  • 1





    @RomeoNinov here we are checking only files...du -b /etc/*.conf

    – msp9011
    Nov 21 '18 at 8:42











  • @msp9011 Not if there is a directory matching the pattern. It's unlikely but not impossible.

    – BlackJack
    Nov 21 '18 at 17:55











  • @msp9011 due to block sizes, etc, disk usage is not the same as total file size.

    – OrangeDog
    Nov 22 '18 at 11:45








5




5





you don't we simply use du?

– msp9011
Nov 21 '18 at 7:30





you don't we simply use du?

– msp9011
Nov 21 '18 at 7:30




1




1





@msp9011, du will calculate also subdirectories

– Romeo Ninov
Nov 21 '18 at 7:39





@msp9011, du will calculate also subdirectories

– Romeo Ninov
Nov 21 '18 at 7:39




1




1





@RomeoNinov here we are checking only files...du -b /etc/*.conf

– msp9011
Nov 21 '18 at 8:42





@RomeoNinov here we are checking only files...du -b /etc/*.conf

– msp9011
Nov 21 '18 at 8:42













@msp9011 Not if there is a directory matching the pattern. It's unlikely but not impossible.

– BlackJack
Nov 21 '18 at 17:55





@msp9011 Not if there is a directory matching the pattern. It's unlikely but not impossible.

– BlackJack
Nov 21 '18 at 17:55













@msp9011 due to block sizes, etc, disk usage is not the same as total file size.

– OrangeDog
Nov 22 '18 at 11:45





@msp9011 due to block sizes, etc, disk usage is not the same as total file size.

– OrangeDog
Nov 22 '18 at 11:45










5 Answers
5






active

oldest

votes


















2














You can do this …



total=0
for s in $(stat /etc/*.conf | grep Size | cut -f4 -d' '); do
total=$(expr $total + $s)
done





share|improve this answer
























  • Thanks! and if I want to output it in a file I do: echo total > my_file.txt, right? And what if I want to output the errors too what do I do then?

    – C. Cristi
    Nov 21 '18 at 7:25






  • 4





    Don't use grep or cut on stat output. stat has format flags (%s) for this

    – ohno
    Nov 21 '18 at 10:20






  • 5





    Also, 'Size' is likely to assume an English or "C " locale.

    – xenoid
    Nov 21 '18 at 13:43



















13














Also something like can do the work (with awk)



stat -c "%s" /etc/*.conf|awk '{s+=$1} END {print s}'





share|improve this answer



















  • 1





    It requires you know a little AWK syntax (which, on the whole, is graciously C-like), but AWK is good at "sum up this column in this delimited file and print the total for me." Sometimes I forget. :)

    – TheDudeAbides
    Dec 19 '18 at 19:21





















12














stat -c "%s" /etc/*.conf|paste -sd+|bc -l





share|improve this answer
























  • Although effectively the same as @xenoid's solution, I prefer this because 1) less rigamarole with format strings and remembering to append the final "0"; and 2) while it costs a process, it hews closer to the "one thing well" philosophy. It's also a useful use of the (perhaps underappreciated) paste utility that can be applied to a larger class of problems: separating a bunch of stuff with a delimiter. Another example is "unwrapping" (removing the line breaks from) a text file: paste -sd$' ' inputfile.

    – TheDudeAbides
    Nov 21 '18 at 23:20








  • 2





    @TheDudeAbides, all those things are true about awk. And it use one process less. And IMO is much more readable

    – Romeo Ninov
    Nov 22 '18 at 10:29



















10














With bc



{ stat -c '%s+' /etc/*.conf ; echo 0 ; } | bc



  • The stat format adds a + sign and a continuation character after each size

  • a 0 is appended at the end to close the dangling final +






share|improve this answer































    7














    The most straightforward way is to use du -bc:



    $ du -bc /etc/*.conf
    5139 /etc/man_db.conf
    393 /etc/nsswitch.conf
    5532 total


    If you need to extract only the number of bytes, pipe the output to awk:



    $ du -bc /etc/*.conf | awk 'END { print $1 }'
    5532





    share|improve this answer
























    • Hope ... OP doesn't require the grand total size of all files...

      – msp9011
      Nov 21 '18 at 8:55






    • 1





      Also note that this gives disk usage, not apparent sizes of the files. --apparent-size option may be needed to use apparent sizes.

      – Ruslan
      Nov 21 '18 at 17:04













    • @Ruslan The awk line also strips off the total

      – Izkata
      Nov 21 '18 at 18:09











    • @Izkata oh, indeed, didn't notice this bit.

      – Ruslan
      Nov 21 '18 at 18:49











    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%2f483135%2fadding-size-of-files-using-shell-script%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    5 Answers
    5






    active

    oldest

    votes








    5 Answers
    5






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    2














    You can do this …



    total=0
    for s in $(stat /etc/*.conf | grep Size | cut -f4 -d' '); do
    total=$(expr $total + $s)
    done





    share|improve this answer
























    • Thanks! and if I want to output it in a file I do: echo total > my_file.txt, right? And what if I want to output the errors too what do I do then?

      – C. Cristi
      Nov 21 '18 at 7:25






    • 4





      Don't use grep or cut on stat output. stat has format flags (%s) for this

      – ohno
      Nov 21 '18 at 10:20






    • 5





      Also, 'Size' is likely to assume an English or "C " locale.

      – xenoid
      Nov 21 '18 at 13:43
















    2














    You can do this …



    total=0
    for s in $(stat /etc/*.conf | grep Size | cut -f4 -d' '); do
    total=$(expr $total + $s)
    done





    share|improve this answer
























    • Thanks! and if I want to output it in a file I do: echo total > my_file.txt, right? And what if I want to output the errors too what do I do then?

      – C. Cristi
      Nov 21 '18 at 7:25






    • 4





      Don't use grep or cut on stat output. stat has format flags (%s) for this

      – ohno
      Nov 21 '18 at 10:20






    • 5





      Also, 'Size' is likely to assume an English or "C " locale.

      – xenoid
      Nov 21 '18 at 13:43














    2












    2








    2







    You can do this …



    total=0
    for s in $(stat /etc/*.conf | grep Size | cut -f4 -d' '); do
    total=$(expr $total + $s)
    done





    share|improve this answer













    You can do this …



    total=0
    for s in $(stat /etc/*.conf | grep Size | cut -f4 -d' '); do
    total=$(expr $total + $s)
    done






    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Nov 21 '18 at 7:20









    Red CricketRed Cricket

    1,21431833




    1,21431833













    • Thanks! and if I want to output it in a file I do: echo total > my_file.txt, right? And what if I want to output the errors too what do I do then?

      – C. Cristi
      Nov 21 '18 at 7:25






    • 4





      Don't use grep or cut on stat output. stat has format flags (%s) for this

      – ohno
      Nov 21 '18 at 10:20






    • 5





      Also, 'Size' is likely to assume an English or "C " locale.

      – xenoid
      Nov 21 '18 at 13:43



















    • Thanks! and if I want to output it in a file I do: echo total > my_file.txt, right? And what if I want to output the errors too what do I do then?

      – C. Cristi
      Nov 21 '18 at 7:25






    • 4





      Don't use grep or cut on stat output. stat has format flags (%s) for this

      – ohno
      Nov 21 '18 at 10:20






    • 5





      Also, 'Size' is likely to assume an English or "C " locale.

      – xenoid
      Nov 21 '18 at 13:43

















    Thanks! and if I want to output it in a file I do: echo total > my_file.txt, right? And what if I want to output the errors too what do I do then?

    – C. Cristi
    Nov 21 '18 at 7:25





    Thanks! and if I want to output it in a file I do: echo total > my_file.txt, right? And what if I want to output the errors too what do I do then?

    – C. Cristi
    Nov 21 '18 at 7:25




    4




    4





    Don't use grep or cut on stat output. stat has format flags (%s) for this

    – ohno
    Nov 21 '18 at 10:20





    Don't use grep or cut on stat output. stat has format flags (%s) for this

    – ohno
    Nov 21 '18 at 10:20




    5




    5





    Also, 'Size' is likely to assume an English or "C " locale.

    – xenoid
    Nov 21 '18 at 13:43





    Also, 'Size' is likely to assume an English or "C " locale.

    – xenoid
    Nov 21 '18 at 13:43













    13














    Also something like can do the work (with awk)



    stat -c "%s" /etc/*.conf|awk '{s+=$1} END {print s}'





    share|improve this answer



















    • 1





      It requires you know a little AWK syntax (which, on the whole, is graciously C-like), but AWK is good at "sum up this column in this delimited file and print the total for me." Sometimes I forget. :)

      – TheDudeAbides
      Dec 19 '18 at 19:21


















    13














    Also something like can do the work (with awk)



    stat -c "%s" /etc/*.conf|awk '{s+=$1} END {print s}'





    share|improve this answer



















    • 1





      It requires you know a little AWK syntax (which, on the whole, is graciously C-like), but AWK is good at "sum up this column in this delimited file and print the total for me." Sometimes I forget. :)

      – TheDudeAbides
      Dec 19 '18 at 19:21
















    13












    13








    13







    Also something like can do the work (with awk)



    stat -c "%s" /etc/*.conf|awk '{s+=$1} END {print s}'





    share|improve this answer













    Also something like can do the work (with awk)



    stat -c "%s" /etc/*.conf|awk '{s+=$1} END {print s}'






    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Nov 21 '18 at 7:35









    Romeo NinovRomeo Ninov

    6,57632028




    6,57632028








    • 1





      It requires you know a little AWK syntax (which, on the whole, is graciously C-like), but AWK is good at "sum up this column in this delimited file and print the total for me." Sometimes I forget. :)

      – TheDudeAbides
      Dec 19 '18 at 19:21
















    • 1





      It requires you know a little AWK syntax (which, on the whole, is graciously C-like), but AWK is good at "sum up this column in this delimited file and print the total for me." Sometimes I forget. :)

      – TheDudeAbides
      Dec 19 '18 at 19:21










    1




    1





    It requires you know a little AWK syntax (which, on the whole, is graciously C-like), but AWK is good at "sum up this column in this delimited file and print the total for me." Sometimes I forget. :)

    – TheDudeAbides
    Dec 19 '18 at 19:21







    It requires you know a little AWK syntax (which, on the whole, is graciously C-like), but AWK is good at "sum up this column in this delimited file and print the total for me." Sometimes I forget. :)

    – TheDudeAbides
    Dec 19 '18 at 19:21













    12














    stat -c "%s" /etc/*.conf|paste -sd+|bc -l





    share|improve this answer
























    • Although effectively the same as @xenoid's solution, I prefer this because 1) less rigamarole with format strings and remembering to append the final "0"; and 2) while it costs a process, it hews closer to the "one thing well" philosophy. It's also a useful use of the (perhaps underappreciated) paste utility that can be applied to a larger class of problems: separating a bunch of stuff with a delimiter. Another example is "unwrapping" (removing the line breaks from) a text file: paste -sd$' ' inputfile.

      – TheDudeAbides
      Nov 21 '18 at 23:20








    • 2





      @TheDudeAbides, all those things are true about awk. And it use one process less. And IMO is much more readable

      – Romeo Ninov
      Nov 22 '18 at 10:29
















    12














    stat -c "%s" /etc/*.conf|paste -sd+|bc -l





    share|improve this answer
























    • Although effectively the same as @xenoid's solution, I prefer this because 1) less rigamarole with format strings and remembering to append the final "0"; and 2) while it costs a process, it hews closer to the "one thing well" philosophy. It's also a useful use of the (perhaps underappreciated) paste utility that can be applied to a larger class of problems: separating a bunch of stuff with a delimiter. Another example is "unwrapping" (removing the line breaks from) a text file: paste -sd$' ' inputfile.

      – TheDudeAbides
      Nov 21 '18 at 23:20








    • 2





      @TheDudeAbides, all those things are true about awk. And it use one process less. And IMO is much more readable

      – Romeo Ninov
      Nov 22 '18 at 10:29














    12












    12








    12







    stat -c "%s" /etc/*.conf|paste -sd+|bc -l





    share|improve this answer













    stat -c "%s" /etc/*.conf|paste -sd+|bc -l






    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Nov 21 '18 at 7:22









    Ipor SircerIpor Sircer

    10.9k11124




    10.9k11124













    • Although effectively the same as @xenoid's solution, I prefer this because 1) less rigamarole with format strings and remembering to append the final "0"; and 2) while it costs a process, it hews closer to the "one thing well" philosophy. It's also a useful use of the (perhaps underappreciated) paste utility that can be applied to a larger class of problems: separating a bunch of stuff with a delimiter. Another example is "unwrapping" (removing the line breaks from) a text file: paste -sd$' ' inputfile.

      – TheDudeAbides
      Nov 21 '18 at 23:20








    • 2





      @TheDudeAbides, all those things are true about awk. And it use one process less. And IMO is much more readable

      – Romeo Ninov
      Nov 22 '18 at 10:29



















    • Although effectively the same as @xenoid's solution, I prefer this because 1) less rigamarole with format strings and remembering to append the final "0"; and 2) while it costs a process, it hews closer to the "one thing well" philosophy. It's also a useful use of the (perhaps underappreciated) paste utility that can be applied to a larger class of problems: separating a bunch of stuff with a delimiter. Another example is "unwrapping" (removing the line breaks from) a text file: paste -sd$' ' inputfile.

      – TheDudeAbides
      Nov 21 '18 at 23:20








    • 2





      @TheDudeAbides, all those things are true about awk. And it use one process less. And IMO is much more readable

      – Romeo Ninov
      Nov 22 '18 at 10:29

















    Although effectively the same as @xenoid's solution, I prefer this because 1) less rigamarole with format strings and remembering to append the final "0"; and 2) while it costs a process, it hews closer to the "one thing well" philosophy. It's also a useful use of the (perhaps underappreciated) paste utility that can be applied to a larger class of problems: separating a bunch of stuff with a delimiter. Another example is "unwrapping" (removing the line breaks from) a text file: paste -sd$' ' inputfile.

    – TheDudeAbides
    Nov 21 '18 at 23:20







    Although effectively the same as @xenoid's solution, I prefer this because 1) less rigamarole with format strings and remembering to append the final "0"; and 2) while it costs a process, it hews closer to the "one thing well" philosophy. It's also a useful use of the (perhaps underappreciated) paste utility that can be applied to a larger class of problems: separating a bunch of stuff with a delimiter. Another example is "unwrapping" (removing the line breaks from) a text file: paste -sd$' ' inputfile.

    – TheDudeAbides
    Nov 21 '18 at 23:20






    2




    2





    @TheDudeAbides, all those things are true about awk. And it use one process less. And IMO is much more readable

    – Romeo Ninov
    Nov 22 '18 at 10:29





    @TheDudeAbides, all those things are true about awk. And it use one process less. And IMO is much more readable

    – Romeo Ninov
    Nov 22 '18 at 10:29











    10














    With bc



    { stat -c '%s+' /etc/*.conf ; echo 0 ; } | bc



    • The stat format adds a + sign and a continuation character after each size

    • a 0 is appended at the end to close the dangling final +






    share|improve this answer




























      10














      With bc



      { stat -c '%s+' /etc/*.conf ; echo 0 ; } | bc



      • The stat format adds a + sign and a continuation character after each size

      • a 0 is appended at the end to close the dangling final +






      share|improve this answer


























        10












        10








        10







        With bc



        { stat -c '%s+' /etc/*.conf ; echo 0 ; } | bc



        • The stat format adds a + sign and a continuation character after each size

        • a 0 is appended at the end to close the dangling final +






        share|improve this answer













        With bc



        { stat -c '%s+' /etc/*.conf ; echo 0 ; } | bc



        • The stat format adds a + sign and a continuation character after each size

        • a 0 is appended at the end to close the dangling final +







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 21 '18 at 10:06









        xenoidxenoid

        3,1601725




        3,1601725























            7














            The most straightforward way is to use du -bc:



            $ du -bc /etc/*.conf
            5139 /etc/man_db.conf
            393 /etc/nsswitch.conf
            5532 total


            If you need to extract only the number of bytes, pipe the output to awk:



            $ du -bc /etc/*.conf | awk 'END { print $1 }'
            5532





            share|improve this answer
























            • Hope ... OP doesn't require the grand total size of all files...

              – msp9011
              Nov 21 '18 at 8:55






            • 1





              Also note that this gives disk usage, not apparent sizes of the files. --apparent-size option may be needed to use apparent sizes.

              – Ruslan
              Nov 21 '18 at 17:04













            • @Ruslan The awk line also strips off the total

              – Izkata
              Nov 21 '18 at 18:09











            • @Izkata oh, indeed, didn't notice this bit.

              – Ruslan
              Nov 21 '18 at 18:49
















            7














            The most straightforward way is to use du -bc:



            $ du -bc /etc/*.conf
            5139 /etc/man_db.conf
            393 /etc/nsswitch.conf
            5532 total


            If you need to extract only the number of bytes, pipe the output to awk:



            $ du -bc /etc/*.conf | awk 'END { print $1 }'
            5532





            share|improve this answer
























            • Hope ... OP doesn't require the grand total size of all files...

              – msp9011
              Nov 21 '18 at 8:55






            • 1





              Also note that this gives disk usage, not apparent sizes of the files. --apparent-size option may be needed to use apparent sizes.

              – Ruslan
              Nov 21 '18 at 17:04













            • @Ruslan The awk line also strips off the total

              – Izkata
              Nov 21 '18 at 18:09











            • @Izkata oh, indeed, didn't notice this bit.

              – Ruslan
              Nov 21 '18 at 18:49














            7












            7








            7







            The most straightforward way is to use du -bc:



            $ du -bc /etc/*.conf
            5139 /etc/man_db.conf
            393 /etc/nsswitch.conf
            5532 total


            If you need to extract only the number of bytes, pipe the output to awk:



            $ du -bc /etc/*.conf | awk 'END { print $1 }'
            5532





            share|improve this answer













            The most straightforward way is to use du -bc:



            $ du -bc /etc/*.conf
            5139 /etc/man_db.conf
            393 /etc/nsswitch.conf
            5532 total


            If you need to extract only the number of bytes, pipe the output to awk:



            $ du -bc /etc/*.conf | awk 'END { print $1 }'
            5532






            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Nov 21 '18 at 8:43









            Martin FrodlMartin Frodl

            1884




            1884













            • Hope ... OP doesn't require the grand total size of all files...

              – msp9011
              Nov 21 '18 at 8:55






            • 1





              Also note that this gives disk usage, not apparent sizes of the files. --apparent-size option may be needed to use apparent sizes.

              – Ruslan
              Nov 21 '18 at 17:04













            • @Ruslan The awk line also strips off the total

              – Izkata
              Nov 21 '18 at 18:09











            • @Izkata oh, indeed, didn't notice this bit.

              – Ruslan
              Nov 21 '18 at 18:49



















            • Hope ... OP doesn't require the grand total size of all files...

              – msp9011
              Nov 21 '18 at 8:55






            • 1





              Also note that this gives disk usage, not apparent sizes of the files. --apparent-size option may be needed to use apparent sizes.

              – Ruslan
              Nov 21 '18 at 17:04













            • @Ruslan The awk line also strips off the total

              – Izkata
              Nov 21 '18 at 18:09











            • @Izkata oh, indeed, didn't notice this bit.

              – Ruslan
              Nov 21 '18 at 18:49

















            Hope ... OP doesn't require the grand total size of all files...

            – msp9011
            Nov 21 '18 at 8:55





            Hope ... OP doesn't require the grand total size of all files...

            – msp9011
            Nov 21 '18 at 8:55




            1




            1





            Also note that this gives disk usage, not apparent sizes of the files. --apparent-size option may be needed to use apparent sizes.

            – Ruslan
            Nov 21 '18 at 17:04







            Also note that this gives disk usage, not apparent sizes of the files. --apparent-size option may be needed to use apparent sizes.

            – Ruslan
            Nov 21 '18 at 17:04















            @Ruslan The awk line also strips off the total

            – Izkata
            Nov 21 '18 at 18:09





            @Ruslan The awk line also strips off the total

            – Izkata
            Nov 21 '18 at 18:09













            @Izkata oh, indeed, didn't notice this bit.

            – Ruslan
            Nov 21 '18 at 18:49





            @Izkata oh, indeed, didn't notice this bit.

            – Ruslan
            Nov 21 '18 at 18:49


















            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%2f483135%2fadding-size-of-files-using-shell-script%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







            這個網誌中的熱門文章

            Tangent Lines Diagram Along Smooth Curve

            Yusuf al-Mu'taman ibn Hud

            Zucchini