The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Cannot redirect ouput????? minifish Shell Programming and Scripting 3 02-20-2008 08:15 AM
Wrong Ouput when using printf under SFU ilak1008 Windows & DOS: Issues & Discussions 5 06-02-2007 12:20 AM
Identifying same character and ouput the sum Raynon Shell Programming and Scripting 12 03-21-2007 07:59 PM
capture the ouput! azmathshaikh Shell Programming and Scripting 0 12-20-2005 03:23 AM
Locating files and directing ouput klannon Filesystems, Disks and Memory 2 03-10-2002 08:57 PM

Closed Thread
 
Submit Tools LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 04-09-2003
Registered User
 

Join Date: Sep 2002
Location: /dev/null
Posts: 12
Stumble this Post!
Red Hat - ouput capture

Red Hat 7.2

On command line.. i need to ouput or capture just..

CPE3236313839393 Fri Nov 1 00:05 - 00:05 (00:00)

the time inside the brackets (00:00) ... i havea list of about a hundred from sperate dates in a long file.

I need to some how grep or i dunno all times from Nov 1 and get the total time for a spread sheet.

Anyone know how??
__________________
[url=http://www.juxtapresentations.com][img]http://members.rogers.com/juxtapresentations.com/myfooter.gif[/img][/url]

[url=www.urbanfocus.ca]Novice Photography Showcase[/url]
Forum Sponsor
  #2 (permalink)  
Old 04-09-2003
TioTony's Avatar
Bit Pusher
 

Join Date: Oct 2001
Location: Southern California
Posts: 332
Stumble this Post!
Not sure if you want a total or to just get a list of time for Nov 1 so here are both.

To get a total from command line:

# grep "Nov 1" yourfile.txt | wc -l

Don't think that is what you want, but just in case.

To get each instance:

# grep "Nov 1" yourfile.txt | awk -F\( '{print $2}' | sed 's/)//g'
  #3 (permalink)  
Old 04-09-2003
Registered User
 

Join Date: Sep 2002
Location: /dev/null
Posts: 12
Stumble this Post!
Quote:
Originally posted by TioTony
Not sure if you want a total or to just get a list of time for Nov 1 so here are both.

To get a total from command line:

# grep "Nov 1" yourfile.txt | wc -l

Don't think that is what you want, but just in case.

To get each instance:

# grep "Nov 1" yourfile.txt | awk -F\( '{print $2}' | sed 's/)//g'
Will that get just the times from any line that has Nov 1??

And how do i output that? just > file.txt at the end?
__________________
[url=http://www.juxtapresentations.com][img]http://members.rogers.com/juxtapresentations.com/myfooter.gif[/img][/url]

[url=www.urbanfocus.ca]Novice Photography Showcase[/url]
  #4 (permalink)  
Old 04-10-2003
oombera's Avatar
Have a day :|
 

Join Date: Aug 2002
Location: Cleveland, OH
Posts: 804
Stumble this Post!
I took it a step further to actually add up the times in case you want to use the total:
Code:
totHr=0
totMn=0

times=`grep "Nov 1" a | awk -F\( '{print $2}' | sed 's/)//g'`
for tm in $times
do
  tmp=`echo $tm | awk '{ print substr($0,1,2) }'`
  totHr=`expr $totHr + $tmp`

  tmp=`echo $tm | awk '{ print substr($0,4,2) }'`
  totMn=`expr $totMn + $tmp`
done

totHr=`expr $totHr + $totMn / 60`
totMn=`expr $totMn % 60`

echo $totHr "hrs," $totMn "min"
Google The UNIX and Linux Forums
Closed Thread

Thread Tools
Display Modes




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


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

Content Relevant URLs by vBSEO 3.2.0