General TC > Programming & Scripting - Unofficial
bash tee command?
(1/1)
coreplayer2:
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:
--- Code: ---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
--- End code ---
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.?
gerald_clark:
This is not a tc/mc issue and could easily be answered by reading the online bash docs.
coreplayer2:
Thank's I've been reading these the man pages and other docs for a while and am fairly sure I have a good grasp on the command, Just asking those who are more experienced is all. Especially as there may be something specific to tc which may be affecting the outcome which I am not aware off.
Forgive me I thought this was the Unofficial Programming & Scripting section..
Navigation
[0] Message Index
Go to full version