The command df [-h]
gives the used/remaining space on all disks.
Can I somehow pipe this output to a different command and get the usage for my current disk (current disk = disk where my current working directory) is located?
The command df [-h]
gives the used/remaining space on all disks.
Can I somehow pipe this output to a different command and get the usage for my current disk (current disk = disk where my current working directory) is located?
You can tell df
to operate on any directory you like; thus
df -h .
will report the available space on the filesystem containing the current directory.
where my current working directory) is located?
running du -sh
in your current working directory gives very simple and direct output of how much space is in and under the current working directory... as in 26M
for example when I do it in my current working directory that has like couple subfolders and a handful of text files.
unless you must use df
for some reason, based on what you are asking it sounds like you should be using du
instead
also : https://www.redhat.com/sysadmin/du-vs-df
The (very complicated) answer can be best summarized like this: The df command provides a sweeping ballpark figure for how much space is being utilized on your filesystem as a whole. The du command is a much more accurate snapshot of a given directory or subdirectory.
du
since I did not need " direct output of how much space is in ". I needed exactly what df
does. I just did not want to parse it using a shell script and filter out for the current disk. Stephen's answer does exactly what was needed in a very clearn fashion.
– lifezbeautiful
Dec 08 '22 at 14:48
du
misses them. That completely kills the accuracy of du
on a file system level.
– Andrew Henle
Dec 08 '22 at 21:48
df
reports on filesystems, not disks. If you need to know the usage of the entire disk, you'll likely need to do some scripting to sum the usage of each partition (and do something sensible with unused/swap/other-os partitions). – Toby Speight Dec 09 '22 at 13:50