Q: cant pipe SLURM `module list`command I am working on a SLURM cluster and there is a command to list all loaded software modules. I want to process the output and i.e. grep it for a certain word. However if I try to use the pipe I get unexpected output which I don't understand.
$ module list

Currently Loaded Modules:
  1) miniconda3-4.8.2-gcc-8.3.1-altn3cq

$ which module
module ()
{ 
    eval $($LMOD_CMD bash "$@") && eval $(${LMOD_SETTARG_CMD:-:} -s sh)
}

$ module list | wc -l

Currently Loaded Modules:
  1) miniconda3-4.8.2-gcc-8.3.1-altn3cq



0

$ module list | grep conda

Currently Loaded Modules:
  1) miniconda3-4.8.2-gcc-8.3.1-altn3cq

 


Thus I am wondering why I can't pipe the output of module list

A: It seems like the command send the output to STDERR instead of STDIN. And because the terminal display both of them you get the things on this way. To send STDERR to STDIN and be able to filter the command output you can use this way:
module list 2>&1 | grep conda

