|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now! |
|
#1
|
|||
|
|||
|
Advanced sed replace help needed
guys,
I need some help with a sed command. The lines I have look like this, but sometimes when there is no error only the last line is displayed. If a line with Exited is displayed ( like beneath) I need to get that and I always need to get the cpu time. Which by the way is now 0.2 but could easely be 20 or something like that. Exited with exit code 2. The CPU time used 0.2 seconds. I tried something. Even though I know it's wrong I'll just write it down. Please only laugh, when you know an answer. s/\(^.*\. \) .*\([0-9\).*$/ \1 \2 /
__________________
Last edited by xyfix : April 18th, 2008 at 07:49 AM. |
|
#2
|
|||
|
|||
|
I got this now, it works but I don't know if this is a lucky guess especially the .*s part doesn't look very nice and how about the cases when there is no error line?
s/\(^.*\. \).*s \(.* \).*$/\2 \1/ |
|
#3
|
|||
|
|||
|
I got it and it works perfect.
#remove the tabs and spaces, this happens when no error message is printed s/^[[:space:]]*// #get the cpu time and the error message s/^\(.*\.\s\)\{0,1\}.*s\s\([0-9]*\.\{0,1\}[0-9]*\)\(.*\)$/\2 \1/ |
|
#4
|
|||
|
|||
|
in my previous posting I gave a solution of my problem, but I should mention that this works on linux not on a SUN OS 5.8.
I translated this working linux line s/^\(.*\.\s\)\{0,1\}.*s\s\([0-9]*\.\{0,1\}[0-9]*\)\(.*\)$/\2 \1/ to s/^\(.*\.[ \t]\).*s[ \t]\([0-9]*\.[0-9]*\)\(.*\)$/\2 \1/ but the zero or one time occurrence does not work. I even tried the ? character. Can Somebody help me out please? Why on earth doesn't sed work the same on all *unix platforms? |
|
#5
|
|||
|
|||
|
I got it, this works with gnu sed and not the sed on the solaris 5.8.
s/^\(.*\.[ \t]\)\?.*s[ \t]\([0-9]*\.\?[0-9]*\).*$/\2 \1/ |
![]() |
| Viewing: Dev Shed Forums > Operating Systems > UNIX Help > Advanced sed replace help needed |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|