How to get the available space of $HOME as a variable in shell scripting? The 2019 Stack...

How can I create a character who can assume the widest possible range of creature sizes?

What could be the right powersource for 15 seconds lifespan disposable giant chainsaw?

Idiomatic way to prevent slicing?

Where does the "burst of radiance" from Holy Weapon originate?

How long do I have to send payment?

Time travel alters history but people keep saying nothing's changed

Why is it "Tumoren" and not "Tumore"?

How to make payment on the internet without leaving a money trail?

Does a dangling wire really electrocute me if I'm standing in water?

Is there a name of the flying bionic bird?

Could JWST stay at L2 "forever"?

I looked up a future colleague on LinkedIn before I started a job. I told my colleague about it and he seemed surprised. Should I apologize?

On the insanity of kings as an argument against monarchy

How are circuits which use complex ICs normally simulated?

Where to refill my bottle in India?

Pristine Bit Checking

What is this 4-propeller plane?

How was Skylab's orbit inclination chosen?

How to manage monthly salary

What do the Banks children have against barley water?

How to change the limits of integration

Does it makes sense to buy a new cycle to learn riding?

Are there any other methods to apply to solving simultaneous equations?

Can't find the latex code for the ⍎ (down tack jot) symbol



How to get the available space of $HOME as a variable in shell scripting?



The 2019 Stack Overflow Developer Survey Results Are InUbuntu server terminal?Is bash scripting the same as shell scripting?Concatenation in Shell Scripting BashShell ScriptingShell Scripting Function questionShell scripting add slashes in file name with spaceShell scripting,Case sensitivity in shell scriptingbash shell scripting errorWhat graphical libraries are available for Bash shell scripting?





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







2















I am writing a bash script to install a program for different users.



For that I want to make sure that each user has at least 500Mb available in their $HOME. My $HOME directory looks as follows



jen@ser23:~$ df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 2,9G 1,1G 1,7G 40% /
udev 10M 0 10M 0% /dev
tmpfs 13G 826M 12G 7% /run
/dev/sda3 15G 9,8G 4,1G 71% /usr
tmpfs 32G 0 32G 0% /dev/shm
tmpfs 5,0M 0 5,0M 0% /run/lock
tmpfs 32G 0 32G 0% /sys/fs/cgroup
/dev/mapper/local_disk_1-tmp 3,7G 21M 3,7G 1% /tmp
/dev/mapper/local_disk_1-opt 20G 2,0G 18G 10% /opt
/dev/mapper/local_disk_1-project1 401G 287G 114G 72% /project1
/dev/mapper/local_disk_1-var 3,8G 1,7G 1,7G 50% /var
/dev/mapper/local_disk_1-project2 99G 70G 29G 71% /project2
/dev/mapper/local_disk_1-usr_local 2,0G 3,4M 1,9G 1% /usr/local
nfs4.sf0.ise.fhg.de:/g/6/TSB/Archiv 632T 349T 276T 56% /net/p/600/groupdrives/TSB/Archiv
nfs4.sf0.ise.fhg.de:/home 632T 349T 276T 56% /net/home
tmpfs 6,4G 0 6,4G 0% /run/user/12419
tmpfs 6,4G 4,0K 6,4G 1% /run/user/13471
tmpfs 6,4G 4,0K 6,4G 1% /run/user/9351
tmpfs 6,4G 0 6,4G 0% /run/user/13142


My idea is to use df -h /path/to/home | awk but I am not sure how I can get the actual available space from df -h. Any help please? Thanks, Jen.



jen@ser23:~$ df -P /net/home/j/jen
Filesystem 1024-blocks Used Available Capacity Mounted on
nfs4.sf0.dfd.fhg.de:/home 5242880 1026048 4216832 20% /net/home









share|improve this question




















  • 1





    @EODCraft Staff : Nop! :)

    – Jenny
    2 days ago






  • 1





    df -P /path/to/home | awk 'NR>1 {print $4}'?

    – Cyrus
    2 days ago








  • 1





    There's no 1,7G. There's at the moment 4216832.

    – Cyrus
    2 days ago








  • 1





    Ah! I thought I should actually get the space in the partition /dev/sda1 2,9G 1,1G 1,7G 40% /

    – Jenny
    2 days ago






  • 1





    If you’re on a big shared system, it’s quite possible that individual accounts have quotas, separate from the available mounted storage. For example, at my old institution, you used the diskquota command to check the available space. You may want to check if an equivalent system exists at your institution.

    – nneonneo
    2 days ago


















2















I am writing a bash script to install a program for different users.



For that I want to make sure that each user has at least 500Mb available in their $HOME. My $HOME directory looks as follows



jen@ser23:~$ df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 2,9G 1,1G 1,7G 40% /
udev 10M 0 10M 0% /dev
tmpfs 13G 826M 12G 7% /run
/dev/sda3 15G 9,8G 4,1G 71% /usr
tmpfs 32G 0 32G 0% /dev/shm
tmpfs 5,0M 0 5,0M 0% /run/lock
tmpfs 32G 0 32G 0% /sys/fs/cgroup
/dev/mapper/local_disk_1-tmp 3,7G 21M 3,7G 1% /tmp
/dev/mapper/local_disk_1-opt 20G 2,0G 18G 10% /opt
/dev/mapper/local_disk_1-project1 401G 287G 114G 72% /project1
/dev/mapper/local_disk_1-var 3,8G 1,7G 1,7G 50% /var
/dev/mapper/local_disk_1-project2 99G 70G 29G 71% /project2
/dev/mapper/local_disk_1-usr_local 2,0G 3,4M 1,9G 1% /usr/local
nfs4.sf0.ise.fhg.de:/g/6/TSB/Archiv 632T 349T 276T 56% /net/p/600/groupdrives/TSB/Archiv
nfs4.sf0.ise.fhg.de:/home 632T 349T 276T 56% /net/home
tmpfs 6,4G 0 6,4G 0% /run/user/12419
tmpfs 6,4G 4,0K 6,4G 1% /run/user/13471
tmpfs 6,4G 4,0K 6,4G 1% /run/user/9351
tmpfs 6,4G 0 6,4G 0% /run/user/13142


My idea is to use df -h /path/to/home | awk but I am not sure how I can get the actual available space from df -h. Any help please? Thanks, Jen.



jen@ser23:~$ df -P /net/home/j/jen
Filesystem 1024-blocks Used Available Capacity Mounted on
nfs4.sf0.dfd.fhg.de:/home 5242880 1026048 4216832 20% /net/home









share|improve this question




















  • 1





    @EODCraft Staff : Nop! :)

    – Jenny
    2 days ago






  • 1





    df -P /path/to/home | awk 'NR>1 {print $4}'?

    – Cyrus
    2 days ago








  • 1





    There's no 1,7G. There's at the moment 4216832.

    – Cyrus
    2 days ago








  • 1





    Ah! I thought I should actually get the space in the partition /dev/sda1 2,9G 1,1G 1,7G 40% /

    – Jenny
    2 days ago






  • 1





    If you’re on a big shared system, it’s quite possible that individual accounts have quotas, separate from the available mounted storage. For example, at my old institution, you used the diskquota command to check the available space. You may want to check if an equivalent system exists at your institution.

    – nneonneo
    2 days ago














2












2








2








I am writing a bash script to install a program for different users.



For that I want to make sure that each user has at least 500Mb available in their $HOME. My $HOME directory looks as follows



jen@ser23:~$ df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 2,9G 1,1G 1,7G 40% /
udev 10M 0 10M 0% /dev
tmpfs 13G 826M 12G 7% /run
/dev/sda3 15G 9,8G 4,1G 71% /usr
tmpfs 32G 0 32G 0% /dev/shm
tmpfs 5,0M 0 5,0M 0% /run/lock
tmpfs 32G 0 32G 0% /sys/fs/cgroup
/dev/mapper/local_disk_1-tmp 3,7G 21M 3,7G 1% /tmp
/dev/mapper/local_disk_1-opt 20G 2,0G 18G 10% /opt
/dev/mapper/local_disk_1-project1 401G 287G 114G 72% /project1
/dev/mapper/local_disk_1-var 3,8G 1,7G 1,7G 50% /var
/dev/mapper/local_disk_1-project2 99G 70G 29G 71% /project2
/dev/mapper/local_disk_1-usr_local 2,0G 3,4M 1,9G 1% /usr/local
nfs4.sf0.ise.fhg.de:/g/6/TSB/Archiv 632T 349T 276T 56% /net/p/600/groupdrives/TSB/Archiv
nfs4.sf0.ise.fhg.de:/home 632T 349T 276T 56% /net/home
tmpfs 6,4G 0 6,4G 0% /run/user/12419
tmpfs 6,4G 4,0K 6,4G 1% /run/user/13471
tmpfs 6,4G 4,0K 6,4G 1% /run/user/9351
tmpfs 6,4G 0 6,4G 0% /run/user/13142


My idea is to use df -h /path/to/home | awk but I am not sure how I can get the actual available space from df -h. Any help please? Thanks, Jen.



jen@ser23:~$ df -P /net/home/j/jen
Filesystem 1024-blocks Used Available Capacity Mounted on
nfs4.sf0.dfd.fhg.de:/home 5242880 1026048 4216832 20% /net/home









share|improve this question
















I am writing a bash script to install a program for different users.



For that I want to make sure that each user has at least 500Mb available in their $HOME. My $HOME directory looks as follows



jen@ser23:~$ df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 2,9G 1,1G 1,7G 40% /
udev 10M 0 10M 0% /dev
tmpfs 13G 826M 12G 7% /run
/dev/sda3 15G 9,8G 4,1G 71% /usr
tmpfs 32G 0 32G 0% /dev/shm
tmpfs 5,0M 0 5,0M 0% /run/lock
tmpfs 32G 0 32G 0% /sys/fs/cgroup
/dev/mapper/local_disk_1-tmp 3,7G 21M 3,7G 1% /tmp
/dev/mapper/local_disk_1-opt 20G 2,0G 18G 10% /opt
/dev/mapper/local_disk_1-project1 401G 287G 114G 72% /project1
/dev/mapper/local_disk_1-var 3,8G 1,7G 1,7G 50% /var
/dev/mapper/local_disk_1-project2 99G 70G 29G 71% /project2
/dev/mapper/local_disk_1-usr_local 2,0G 3,4M 1,9G 1% /usr/local
nfs4.sf0.ise.fhg.de:/g/6/TSB/Archiv 632T 349T 276T 56% /net/p/600/groupdrives/TSB/Archiv
nfs4.sf0.ise.fhg.de:/home 632T 349T 276T 56% /net/home
tmpfs 6,4G 0 6,4G 0% /run/user/12419
tmpfs 6,4G 4,0K 6,4G 1% /run/user/13471
tmpfs 6,4G 4,0K 6,4G 1% /run/user/9351
tmpfs 6,4G 0 6,4G 0% /run/user/13142


My idea is to use df -h /path/to/home | awk but I am not sure how I can get the actual available space from df -h. Any help please? Thanks, Jen.



jen@ser23:~$ df -P /net/home/j/jen
Filesystem 1024-blocks Used Available Capacity Mounted on
nfs4.sf0.dfd.fhg.de:/home 5242880 1026048 4216832 20% /net/home






command-line bash scripts






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 2 days ago







Jenny

















asked 2 days ago









JennyJenny

1018




1018








  • 1





    @EODCraft Staff : Nop! :)

    – Jenny
    2 days ago






  • 1





    df -P /path/to/home | awk 'NR>1 {print $4}'?

    – Cyrus
    2 days ago








  • 1





    There's no 1,7G. There's at the moment 4216832.

    – Cyrus
    2 days ago








  • 1





    Ah! I thought I should actually get the space in the partition /dev/sda1 2,9G 1,1G 1,7G 40% /

    – Jenny
    2 days ago






  • 1





    If you’re on a big shared system, it’s quite possible that individual accounts have quotas, separate from the available mounted storage. For example, at my old institution, you used the diskquota command to check the available space. You may want to check if an equivalent system exists at your institution.

    – nneonneo
    2 days ago














  • 1





    @EODCraft Staff : Nop! :)

    – Jenny
    2 days ago






  • 1





    df -P /path/to/home | awk 'NR>1 {print $4}'?

    – Cyrus
    2 days ago








  • 1





    There's no 1,7G. There's at the moment 4216832.

    – Cyrus
    2 days ago








  • 1





    Ah! I thought I should actually get the space in the partition /dev/sda1 2,9G 1,1G 1,7G 40% /

    – Jenny
    2 days ago






  • 1





    If you’re on a big shared system, it’s quite possible that individual accounts have quotas, separate from the available mounted storage. For example, at my old institution, you used the diskquota command to check the available space. You may want to check if an equivalent system exists at your institution.

    – nneonneo
    2 days ago








1




1





@EODCraft Staff : Nop! :)

– Jenny
2 days ago





@EODCraft Staff : Nop! :)

– Jenny
2 days ago




1




1





df -P /path/to/home | awk 'NR>1 {print $4}'?

– Cyrus
2 days ago







df -P /path/to/home | awk 'NR>1 {print $4}'?

– Cyrus
2 days ago






1




1





There's no 1,7G. There's at the moment 4216832.

– Cyrus
2 days ago







There's no 1,7G. There's at the moment 4216832.

– Cyrus
2 days ago






1




1





Ah! I thought I should actually get the space in the partition /dev/sda1 2,9G 1,1G 1,7G 40% /

– Jenny
2 days ago





Ah! I thought I should actually get the space in the partition /dev/sda1 2,9G 1,1G 1,7G 40% /

– Jenny
2 days ago




1




1





If you’re on a big shared system, it’s quite possible that individual accounts have quotas, separate from the available mounted storage. For example, at my old institution, you used the diskquota command to check the available space. You may want to check if an equivalent system exists at your institution.

– nneonneo
2 days ago





If you’re on a big shared system, it’s quite possible that individual accounts have quotas, separate from the available mounted storage. For example, at my old institution, you used the diskquota command to check the available space. You may want to check if an equivalent system exists at your institution.

– nneonneo
2 days ago










3 Answers
3






active

oldest

votes


















4














The important point to remember is that df operates on filesystems, which may be attached to particular folders, and if you specify a path or file, it will resolve to usage of the filesystem on which file/folder resides. So df -P /net/home/j/jen operates on the filesystem mounted at /net/home, which is nfs4.sf0.ise.fhg.de network attached storage apparently.



The usage of a directory and all the files requires a recursive solution that will traverse files and directories within particular directory. The tool that you seek then, is du and in particular du -shx /net/home/user.



Keypoints (for more read man du):





  • du is recursive by default


  • -s provides summary instead of listing filesizes individually


  • -h provides human readable output. If you require further processing on data, -b might be more preferable.


  • -x is to keep du descending into another. For instance, you could have another network server attached to /net/home/user/anotherplace, so processing that directory is undesirable as it will give incorrect filesystem usage results.


Considering that this is an assignment, further processing and manipulations on output of du are left to the reader to implement






share|improve this answer

































    1














    It looks like you're heading towards a workable solution already in the comments, but I'm going to throw this in:



    DFHOME=$( df $HOME | awk {'print $4;'} | tail -n 1 )
    if [ $DFHOME -lt 500000 ]; then
    echo "You don't got enough space!";
    fi


    I'd recommend not using -h because if the size is small enough, the G will turn to an M and your solution might break.






    share|improve this answer

































      1














      No need to parse df output with awk, you can use --output switch:



      df --output=avail "$HOME" | tail -n1





      --output[=FIELD_LIST]

      use the output format defined by FIELD_LIST, or print all fields if FIELD_LIST is omitted.



      FIELD_LIST is a comma-separated list of columns to be included. Valid field names are: 'source', 'fstype', 'itotal', 'iused', 'iavail', 'ipcent', 'size', 'used', 'avail', 'pcent', 'file' and 'tar‐
      get'







      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/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%2faskubuntu.com%2fquestions%2f1131935%2fhow-to-get-the-available-space-of-home-as-a-variable-in-shell-scripting%23new-answer', 'question_page');
        }
        );

        Post as a guest















        Required, but never shown

























        3 Answers
        3






        active

        oldest

        votes








        3 Answers
        3






        active

        oldest

        votes









        active

        oldest

        votes






        active

        oldest

        votes









        4














        The important point to remember is that df operates on filesystems, which may be attached to particular folders, and if you specify a path or file, it will resolve to usage of the filesystem on which file/folder resides. So df -P /net/home/j/jen operates on the filesystem mounted at /net/home, which is nfs4.sf0.ise.fhg.de network attached storage apparently.



        The usage of a directory and all the files requires a recursive solution that will traverse files and directories within particular directory. The tool that you seek then, is du and in particular du -shx /net/home/user.



        Keypoints (for more read man du):





        • du is recursive by default


        • -s provides summary instead of listing filesizes individually


        • -h provides human readable output. If you require further processing on data, -b might be more preferable.


        • -x is to keep du descending into another. For instance, you could have another network server attached to /net/home/user/anotherplace, so processing that directory is undesirable as it will give incorrect filesystem usage results.


        Considering that this is an assignment, further processing and manipulations on output of du are left to the reader to implement






        share|improve this answer






























          4














          The important point to remember is that df operates on filesystems, which may be attached to particular folders, and if you specify a path or file, it will resolve to usage of the filesystem on which file/folder resides. So df -P /net/home/j/jen operates on the filesystem mounted at /net/home, which is nfs4.sf0.ise.fhg.de network attached storage apparently.



          The usage of a directory and all the files requires a recursive solution that will traverse files and directories within particular directory. The tool that you seek then, is du and in particular du -shx /net/home/user.



          Keypoints (for more read man du):





          • du is recursive by default


          • -s provides summary instead of listing filesizes individually


          • -h provides human readable output. If you require further processing on data, -b might be more preferable.


          • -x is to keep du descending into another. For instance, you could have another network server attached to /net/home/user/anotherplace, so processing that directory is undesirable as it will give incorrect filesystem usage results.


          Considering that this is an assignment, further processing and manipulations on output of du are left to the reader to implement






          share|improve this answer




























            4












            4








            4







            The important point to remember is that df operates on filesystems, which may be attached to particular folders, and if you specify a path or file, it will resolve to usage of the filesystem on which file/folder resides. So df -P /net/home/j/jen operates on the filesystem mounted at /net/home, which is nfs4.sf0.ise.fhg.de network attached storage apparently.



            The usage of a directory and all the files requires a recursive solution that will traverse files and directories within particular directory. The tool that you seek then, is du and in particular du -shx /net/home/user.



            Keypoints (for more read man du):





            • du is recursive by default


            • -s provides summary instead of listing filesizes individually


            • -h provides human readable output. If you require further processing on data, -b might be more preferable.


            • -x is to keep du descending into another. For instance, you could have another network server attached to /net/home/user/anotherplace, so processing that directory is undesirable as it will give incorrect filesystem usage results.


            Considering that this is an assignment, further processing and manipulations on output of du are left to the reader to implement






            share|improve this answer















            The important point to remember is that df operates on filesystems, which may be attached to particular folders, and if you specify a path or file, it will resolve to usage of the filesystem on which file/folder resides. So df -P /net/home/j/jen operates on the filesystem mounted at /net/home, which is nfs4.sf0.ise.fhg.de network attached storage apparently.



            The usage of a directory and all the files requires a recursive solution that will traverse files and directories within particular directory. The tool that you seek then, is du and in particular du -shx /net/home/user.



            Keypoints (for more read man du):





            • du is recursive by default


            • -s provides summary instead of listing filesizes individually


            • -h provides human readable output. If you require further processing on data, -b might be more preferable.


            • -x is to keep du descending into another. For instance, you could have another network server attached to /net/home/user/anotherplace, so processing that directory is undesirable as it will give incorrect filesystem usage results.


            Considering that this is an assignment, further processing and manipulations on output of du are left to the reader to implement







            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited yesterday

























            answered 2 days ago









            Sergiy KolodyazhnyySergiy Kolodyazhnyy

            75.1k9155327




            75.1k9155327

























                1














                It looks like you're heading towards a workable solution already in the comments, but I'm going to throw this in:



                DFHOME=$( df $HOME | awk {'print $4;'} | tail -n 1 )
                if [ $DFHOME -lt 500000 ]; then
                echo "You don't got enough space!";
                fi


                I'd recommend not using -h because if the size is small enough, the G will turn to an M and your solution might break.






                share|improve this answer






























                  1














                  It looks like you're heading towards a workable solution already in the comments, but I'm going to throw this in:



                  DFHOME=$( df $HOME | awk {'print $4;'} | tail -n 1 )
                  if [ $DFHOME -lt 500000 ]; then
                  echo "You don't got enough space!";
                  fi


                  I'd recommend not using -h because if the size is small enough, the G will turn to an M and your solution might break.






                  share|improve this answer




























                    1












                    1








                    1







                    It looks like you're heading towards a workable solution already in the comments, but I'm going to throw this in:



                    DFHOME=$( df $HOME | awk {'print $4;'} | tail -n 1 )
                    if [ $DFHOME -lt 500000 ]; then
                    echo "You don't got enough space!";
                    fi


                    I'd recommend not using -h because if the size is small enough, the G will turn to an M and your solution might break.






                    share|improve this answer















                    It looks like you're heading towards a workable solution already in the comments, but I'm going to throw this in:



                    DFHOME=$( df $HOME | awk {'print $4;'} | tail -n 1 )
                    if [ $DFHOME -lt 500000 ]; then
                    echo "You don't got enough space!";
                    fi


                    I'd recommend not using -h because if the size is small enough, the G will turn to an M and your solution might break.







                    share|improve this answer














                    share|improve this answer



                    share|improve this answer








                    edited 2 days ago

























                    answered 2 days ago









                    KarlKarl

                    215




                    215























                        1














                        No need to parse df output with awk, you can use --output switch:



                        df --output=avail "$HOME" | tail -n1





                        --output[=FIELD_LIST]

                        use the output format defined by FIELD_LIST, or print all fields if FIELD_LIST is omitted.



                        FIELD_LIST is a comma-separated list of columns to be included. Valid field names are: 'source', 'fstype', 'itotal', 'iused', 'iavail', 'ipcent', 'size', 'used', 'avail', 'pcent', 'file' and 'tar‐
                        get'







                        share|improve this answer




























                          1














                          No need to parse df output with awk, you can use --output switch:



                          df --output=avail "$HOME" | tail -n1





                          --output[=FIELD_LIST]

                          use the output format defined by FIELD_LIST, or print all fields if FIELD_LIST is omitted.



                          FIELD_LIST is a comma-separated list of columns to be included. Valid field names are: 'source', 'fstype', 'itotal', 'iused', 'iavail', 'ipcent', 'size', 'used', 'avail', 'pcent', 'file' and 'tar‐
                          get'







                          share|improve this answer


























                            1












                            1








                            1







                            No need to parse df output with awk, you can use --output switch:



                            df --output=avail "$HOME" | tail -n1





                            --output[=FIELD_LIST]

                            use the output format defined by FIELD_LIST, or print all fields if FIELD_LIST is omitted.



                            FIELD_LIST is a comma-separated list of columns to be included. Valid field names are: 'source', 'fstype', 'itotal', 'iused', 'iavail', 'ipcent', 'size', 'used', 'avail', 'pcent', 'file' and 'tar‐
                            get'







                            share|improve this answer













                            No need to parse df output with awk, you can use --output switch:



                            df --output=avail "$HOME" | tail -n1





                            --output[=FIELD_LIST]

                            use the output format defined by FIELD_LIST, or print all fields if FIELD_LIST is omitted.



                            FIELD_LIST is a comma-separated list of columns to be included. Valid field names are: 'source', 'fstype', 'itotal', 'iused', 'iavail', 'ipcent', 'size', 'used', 'avail', 'pcent', 'file' and 'tar‐
                            get'








                            share|improve this answer












                            share|improve this answer



                            share|improve this answer










                            answered yesterday









                            RoVoRoVo

                            8,1811943




                            8,1811943






























                                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%2f1131935%2fhow-to-get-the-available-space-of-home-as-a-variable-in-shell-scripting%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

                                Couldn't open a raw socket. Error: Permission denied (13) (nmap)Is it possible to run networking commands...

                                VNC viewer RFB protocol error: bad desktop size 0x0I Cannot Type the Key 'd' (lowercase) in VNC Viewer...

                                Why not use the yoke to control yaw, as well as pitch and roll? Announcing the arrival of...