From: Jon LaBadie on
Stu wrote:
> On Jul 9, 9:20 pm, Janis Papanagnou <janis_papanag...(a)hotmail.com>
> wrote:
>> On 09/07/10 17:17, Ben Bacarisse wrote:
>>
>>> Janis Papanagnou <janis_papanag...(a)hotmail.com> writes:
>>> <snip>
>>>> But for your task I'd suggest to resort to Icarus' last suggestion which is
>>>> most simple and portable.
>>> Icarus' solution assumed the time came from a data command whose format
>>> could be altered to get the desired effect. That may fit the bill here
>>> but it is not a solution to the question as asked.
>> You're right. Here's one using eval without assuming a date command
>>
>> eval $( printf "cpu_hh=%s cpu_mm=%s cpu_sec=%s" ${cpu_time//:/ } )
>>
>> though non-POSIX because of the variable substitution it works only
>> with modern shells.
>>
>> Janis
>>
>>
>>
>>
>>
>>> <snip>- Hide quoted text -
>> - Show quoted text -
>
> What would be considered a modern shell, bash? This, does not work
> with ksh. I already found
> the solution, but I am very interested in other methods to skin the
> perverbial cat.
>
>
> cpu_time=23:12:56
> eval $(printf "cpu_hh=%s cpu_mm=%s cpu_sec=%s" ${cpu_time//:/})
>
> ${cpu_time//:/}: 0403-011 The specified substitution is not valid for
> this command.

If you try it on a shell that supports substitution, include the space
that is supposed to replace the colons.

${cpu_time//:/ }
^

jl
First  |  Prev  | 
Pages: 1 2 3 4 5
Prev: rm in a regular expression
Next: Pattern matching