Advertisement
jglathe

Untitled

Jun 26th, 2024
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. # Run the sensors command and process the output
  4. sensors | while IFS= read -r line
  5. do
  6. # If the line starts with "Composite:", "temp", or "Sensor", extract the temperature
  7. if [[ "$line" == temp* || "$line" == Composite:* ]]; then
  8. temp=$(echo "$line" | awk '{print $2}')
  9. echo -e "$device\t$temp"
  10. elif [[ "$line" == Sensor* ]]; then
  11. temp=$(echo "$line" | awk '{print $3}')
  12. echo -e "$device\t$temp"
  13. fi
  14.  
  15. # If the line contains "Adapter:", store the previous line as the device name
  16. if echo "$line" | grep -q 'Adapter:'; then
  17. device=$(echo "$previous_line")
  18. fi
  19.  
  20. # Store the current line as the previous line for the next iteration
  21. previous_line="$line"
  22. done
  23.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement