regex - using sed to extract a time from a line -


line:

0.01user 0.00system 0:13.46elapsed 0%cpu (0avgtext+0avgdata 4272maxresident)k 

i want grab:

0:13.46 

my current regex is:

sed 's/.*\([0-9]*:[0-9]*.[0-9]*\)elapsed.*/\1/' 

i'm pretty sure regex correct, it's not finding anything. it's simple, i'm doing 10 things @ once.

this works me:

% sed 's/.*\s\([0-9]*:[0-9]*.[0-9]*\)elapsed.*/\1/' 0.01user 0.00system 0:13.46elapsed 0%cpu (0avgtext+0avgdata 4272maxresident)k 0:13.46 

note how put \s before first digit want match.

then again, regex kind of worked me before in print out :13.46 (the .* gobbled first 0 want print out).


Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -