Bash – show only physical disks when using df and mount

aliasbashdisk-usagefunctionmount

When I use df or mount, I'm most of all interested in physical disk partitions. Nowadays the output of those commands is overwhelmed by temporary and virtual filesystems, cgroups and other things I am not interested in on a regular basis.

My physical partitions in the output always start with '/', so I tried making aliases for df and mount:

alias df1="df | egrep '^/'"
alias mount1="mount | egrep '^/'"

That works OK for mount1 (although it shows the '/' in red), but for df1 I would sometimes like to add the -h option to df and cannot do df1 -h. I would prefer not to have an alias for every option combination I might want to use. Do I really have to look into defining functions in bash (I would prefer not to)? Is there a better solution for df1?

Best Answer

You can solve the df1 argument issue by using the following alias:

alias df1='df --type btrfs --type ext4 --type ext3 --type ext2 --type vfat --type iso9660'

make sure to add any other type (xfs, fuseblk (for modern NTFS support, as @Pandya pointed out), etc) you're interested in. With that you can do df1 -h and get the expected result.

mount does have a -t option but you cannot specify it multiple times (only the last is taken), there I would use:

alias mount1="mount | /bin/grep -E '^/'"

I am using grep -E as egrep is deprecated and using /bin/grep makes sure you're not using --colour=auto from an alias for grep/egrep

Related Question