-2

I have this bit of info from a bash script. How can I keep only the time?

"real\t0m3.21s"

Needs to be

3.21s 

The output is produced from time function.

Stat.Enthus
  • 335
  • 1
  • 12
  • What if the output is `2m3.21s` -- you don't care about the 2 minutes? – Barmar Mar 30 '21 at 08:10
  • See https://www.gnu.org/software/bash/manual/html_node/Shell-Parameter-Expansion.html#Shell-Parameter-Expansion for the parameter expansion operators you can use to remove `real\t*m` from the beginning of the string. – Barmar Mar 30 '21 at 08:11

1 Answers1

0

Using sed:

sed -n 's/real\\t0m//p' <<< "real\t0m3.21s"

Replace "read\t0m" for nothing and print

Raman Sailopal
  • 12,320
  • 2
  • 11
  • 18