Hi all,

I got stuck into a problem. I have a variable in which the data is stored as below:

variable_test=0m0.001s 0m0.001s 0m0.001s 0m0.001s 0m0.001s 0m0.001s .....an so on.

There are lots of values in format like "3m1.057s" are stored in variable_test separated with an space between two such values.

For exapmple, value is "3m1.057s"
I need to save different parts of a value in three separate array variables such as
the
var_hour=3
var_min=1
var_sec= 057

Can anyone tell if this can be done using "awk". A "WHILE" loop might be used to separate and store theses values I guess?
Please help me out. Thanks
Edit/Delete Message

If you want to use awk, there is the split() function:

awk -v t=3m1.057s 'BEGIN { split(t,d,/[m.s]/); minute=d[1]; second=d[2]; millisecond=d[3]; print minute, second, millisecond; }'

Using the shell:

(
t=3m1.057s
IFS=m.s
set -f
set -- $t
set +f
minute=$1
second=$2
millisecond=$3
printf "%s %s %s\n" "$minute" "$second" "$millisecond"
)
This question has already been answered. Start a new discussion instead.