Find and order all files by size, save the result to a text file on a Linux system
du -k | sort -nr | awk '
BEGIN {
split("KB,MB,GB,TB", Units, ",");
}
{
u = 1;
while ($1 >= 1024) {
$1 = $1 / 1024;
u += 1
}
$1 = sprintf("%.1f %s", $1, Units[u]);
print $0;
}
' > result_list_ordered.txt
My personal Linux notes, a work in progress, shared online with the world. From intro to pro Linux Administration.
Showing posts with label du. Show all posts
Showing posts with label du. Show all posts
Wednesday, May 1, 2013
Thursday, February 14, 2013
Free Disk Space / Disk usage on Linux
Q. How do I check free disk space in Linux or UNIX operating system? I've migrated from Windows NT to Linux and looking forward to get more information about free disk space.
A. Both Linux and UNIX offers two commands for checking out free disk space:
(a) df command : Report file system disk space usage
(b) du command : Estimate file space usage
df command examples - to check free disk space
Type df -h or df -k to list free disk space:
OR
$ df -hOR
$ df -klinuxServer:/ # df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/sda2 109038804 82892008 20610028 81% /
udev 3864264 92 3864172 1% /dev
/dev/sda3 10079572 5955024 3612484 63% /home
or you can run this command to get the file sizes at depth 1
# du -hc --max-depth=1
Thanks
Labels:
df,
disk space,
disk usage,
du,
free disk space,
space
Subscribe to:
Posts (Atom)