Ok, anyone familiar with the "tee" command?
I've been attempting to modify this function of a script. Currently this line outputs the result of lspci to grep via a pipe, with all errors > black hole. In addition to output > grep I would like to print the same output to a file to be used later.
controllermode=`lspci 2>//dev/null | egrep -i -o "(IDE interface)|(AHCI controller)"`
For the time being, I've added a separate line to deal with this, however I understand there is a "tee" command which splits the stream two ways, does anyone know how to apply this "tee" making the script more efficient?
lspci >//home/tc/pci.log 2>//dev/null
The function:
fsata(){
lspci >//home/tc/pci.log 2>//dev/null #added this line until tee works
controllermode=`lspci 2>//dev/null | egrep -i -o "(IDE interface)|(AHCI controller)"`
echo
echo "Current controller mode(s):"
echo "$controllermode"
echo
}
fsata
I'm new to bash, which is why I've taken a long handed approach (like path's) so if anyone would advise on how to write efficiently, please feel free, I'm all ears.
The more I rationalize this, I'm thinking something like this might work.
lspci 2>//dev/null | tee ~/pci.log | egrep -i -o "(IDE interface)|(AHCI controller)"?
Ok this does appear to work, but is it correct or as efficient as it could be.?