[root@server ~]# df -h Filesystem Size Used Avail Use% Mounted on /dev/mapper/vm-root 18G 7.8G 11G 44% / devtmpfs 1.3G 0 1.3G 0% /dev tmpfs 1.3G 0 1.3G 0% /dev/shm tmpfs 1.3G 9.5M 1.3G 1% /run tmpfs 1.3G 0 1.3G 0% /sys/fs/cgroup /dev/sda1 1014M 287M 728M 29% /boot [root@server ~]# find / -maxdepth 1 -type d | xargs -I {} sh -c "mountpoint -q {} || du -sk {}" | sort -n 0 /mnt 0 /srv 0 /vbox_share 212 /tmp 256 /root 48856 /etc 72692 /media 177668 /opt 933676 /home 2238568 /var 4586604 /usr
Excludes other mountpoints with acavagni's "mountpoint" idea, but with -exec instead of piping to an xargs subshell. Then, calling "du" only once with -exec's "+" option. The first "\! -exec" acts as a test so only those who match are passed to the second "-exec" for du. Show Sample Output
Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?
You must be signed in to comment.
commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.
Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.
» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10
Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):
Subscribe to the feed for: