This question already has an answer here:

I would like to extract substring after colon delimiter for my practical needs using GNU awk utility. For example I can extract the temperature of hdd value using cut as follows

hddtemp /dev/sda | cut -d ':' -f3

The same example written in sed

hddtemp /dev/sda | sed 's/.*\://'

For glory of Saint Completeness and GNU Trinity (awk, cut, sed) I wonder, can GNU awk do such thing?

Sample input: /dev/sda: ST500LT012-9WS142: 47°C

Required output: 47°C

marked as duplicate by don_crissti, αғsнιη, Community Oct 15 '18 at 15:36

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • Please post sample input and required output – Praveen Kumar BS Oct 15 '18 at 15:14
  • @PraveenKumarBS, done! – Twissell Oct 15 '18 at 15:24
  • ... |awk '{ print $NF }' – αғsнιη Oct 15 '18 at 15:27
  • @don_crissti, Yep! awk -F ":" '{print $NF}' also works well. But in that topic the answer wasn't accepted. – Twissell Oct 15 '18 at 15:34
  • 1
    (Sadly...) The best answer isn't always the accepted one... – don_crissti Oct 15 '18 at 15:38

Please find the command

echo "/dev/sda: ST500LT012-9WS142: 47°C" | awk -F ":" '{print $3}'


 echo "/dev/sda: ST500LT012-9WS142: 47°C" | awk -F ":" '{print $3}'

Not the answer you're looking for? Browse other questions tagged or ask your own question.