0

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

Twissell
  • 141

1 Answers1

3

Please find the command

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

output:

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