UNIX Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsOperating SystemsUNIX Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
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  
Old April 17th, 2008, 09:32 AM
xyfix xyfix is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Posts: 245 xyfix User rank is Private First Class (20 - 50 Reputation Level)xyfix User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 1 Day 8 h 5 m 11 sec
Reputation Power: 5
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.

Reply With Quote
  #2  
Old April 17th, 2008, 09:51 AM
xyfix xyfix is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Posts: 245 xyfix User rank is Private First Class (20 - 50 Reputation Level)xyfix User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 1 Day 8 h 5 m 11 sec
Reputation Power: 5
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/

Reply With Quote
  #3  
Old April 18th, 2008, 08:23 AM
xyfix xyfix is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Posts: 245 xyfix User rank is Private First Class (20 - 50 Reputation Level)xyfix User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 1 Day 8 h 5 m 11 sec
Reputation Power: 5
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/

Reply With Quote
  #4  
Old April 22nd, 2008, 03:52 AM
xyfix xyfix is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Posts: 245 xyfix User rank is Private First Class (20 - 50 Reputation Level)xyfix User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 1 Day 8 h 5 m 11 sec
Reputation Power: 5
Question serious help needed from a unix guru

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?

Reply With Quote
  #5  
Old April 23rd, 2008, 03:19 AM
xyfix xyfix is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Posts: 245 xyfix User rank is Private First Class (20 - 50 Reputation Level)xyfix User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 1 Day 8 h 5 m 11 sec
Reputation Power: 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/

Reply With Quote
Reply

Viewing: Dev Shed ForumsOperating SystemsUNIX Help > Advanced sed replace help needed


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway