linuxbashaliaspiping

Can I pipe lshw warnings to /dev/null when I run it as a standard user?


I'm trying to create an alias for getting memory on my machine, currently I have alias mem="lshw | grep size | awk -F: '{print $2}'", and when I run it as a non-super user, I get the following warning message:

WARNING: you should run this program as super-user.
WARNING: output may be incomplete or inaccurate, you should run this program as super-user.
      size: 23GiB

I'm not worried about the results being potentially incomplete, in fact when I diff the output when running as root vs a standard user, it's exactly the same. Does anybody know how to get rid of these warnings? I tried piping stderr to /dev/null, but that didn't work. Does anyone else know how to get rid of these warnings?


Solution

  • Can I interest you in

    alias mem='free -g | grep Mem | awk '\''{print $2 " GiB"}'\'
    

    free -m will give MiB; you can change the " GiB" part to whatever you want (or remove it).

    I don't have lshw installed on my machine, so I can't help you debug your version, unfortunately.