The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
error: initializer expression list treated as compound expression arunchaudhary19 High Level Programming 12 11-16-2007 03:44 AM
Help with Reg. Expression moe2266 UNIX for Dummies Questions & Answers 7 07-16-2007 01:05 PM
OR expression Rock UNIX for Dummies Questions & Answers 3 05-03-2007 05:50 AM
KSH Expression tmarikle Shell Programming and Scripting 4 09-28-2005 01:27 PM
Regular Expression + Aritmetical Expression Z0mby Shell Programming and Scripting 2 05-21-2002 07:59 AM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1  
Old 05-06-2008
Registered User
 

Join Date: Feb 2008
Posts: 38
Reg expression For

HI

system.sysUpTime.0 : Timeticks: (1519411311) 175 days, 20:35:13.11

From the above output i need only 175days in a perl script..

Please Help
Reply With Quote
Forum Sponsor
  #2  
Old 05-06-2008
 

Join Date: May 2008
Location: Sydney, Australia
Posts: 904
Something like this?

Code:
$date="system.sysUpTime.0 : Timeticks: (1519411311) 175 days, 20:35:13.11";
$date=~ s/.* (\d+) days.*/$1/;
Reply With Quote
  #3  
Old 05-06-2008
Yogesh Sawant's Avatar
Part Time Moderator and Full Time Dad
 

Join Date: Sep 2006
Location: Rossem, Tazenda
Posts: 790
try this:
Code:
$str = "system.sysUpTime.0 : Timeticks: (1519411311) 175 days, 20:35:13.11";
if ($str =~ m/(\d+)\s+days/) {
    print $1;
}
Reply With Quote
Google The UNIX and Linux Forums
Reply

Tags
perl, regex

Thread Tools
Display Modes




All times are GMT -7. The time now is 05:40 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0