Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

3
  • will it always have a number on the end? echo "9 Power_On_Hours 0x0032 100 100 000 Old_age Always - 301" | awk ' { print ( $(NF) ) }' Can do the trick. Commented Aug 15, 2013 at 15:13
  • Use awk as in: $SMARTCTL_OUTPUT=$(smartctl -a /dev/sda | awk '/Power_On_Hours/{print $(10)})' I missed 9 at the beginning ;) Commented Aug 15, 2013 at 15:14
  • Yes, the last text on the line is always a number. Commented Aug 15, 2013 at 15:14