What happened to my machine?

Bob Proulx bob at proulx.com
Tue Jun 14 11:33:05 MDT 2022


Jeffrey Means wrote:
> I really wish there was an easy way to look at df without having all
> the snapd and cgroup stuff showing up.    I know there's a -x
> [fstype] switch but still this should be the default to have the
> 'Virtual' filesystems not display on a standard df list.

I hesitate to suggest this because it is truly a hack.  But you might
try putting this in your ~/.bashrc file.

    df() { /bin/df "$@" | awk '$NF!~/^\/run/&&$NF!~/^\/sys/&&$NF!~/^\/dev/&&$NF!~/^\/snap\//'; }

You can paste that into your command line shell and try it before
committing it to the .bashrc file.

This creates a function which does the filtering as I described in my
other message.  It will filter the output of df and remove the noise
which is not useful.

The main problem here is that it *always* filters this out even if you
don't want it filtered out.  Such as some day in the future you will
want to see something and both of these will fail.

    df /snap
    df -a

That's why this is too simple.  It does not know to handle these cases
correctly and will filter the output out from them.  And you would
need to remember to avoid the shell function and to bypass it with a
full path to the binary, or other method.

    /bin/df -a
    /bin/df /snap

Perhaps using a non-overriding name such as "mydf" or something would
be the right way to do this.  It's a total hack as I mentioned.

Bob



More information about the NCLUG mailing list