Ubuntu – How to use grep to find the next 7 characters after “temp1”

grep

how can i get "+45.0°C" if the following output was a file (http://paste.linuxthefish.net/4@raw)?

I can get it to one line by doing

sensors -A acpitz-virtual-0 > sen
grep temp1 ~/sen

but it still has a load of useless crap on it:

"temp1:        +42.0°C  (crit = +90.0°C)"

Best Answer

Here's the answer: For instance these are the texts inside the file

acpitz-virtual-0
Adapter: Virtual device
temp1:        +45.0°C  (crit = +90.0°C)
temp2:        +45.0°C  (crit = +90.0°C)

To get the +45.0°C of temp1, use this command:

grep temp1 < theFileWithTemp.txt | awk '{print $2}'