Sponsored Content
Top Forums Shell Programming and Scripting How to extract start/end times from log file to CSV file? Post 302926313 by Igal Malka on Sunday 23rd of November 2014 07:25:43 AM
Old 11-23-2014
That would do the job

Enjoy...

Code:
#!/bin/bash

numOfRecords=0
prevDay=`head -1 log.txt| awk '{print $1}'`
startTime=`head -1 log.txt| awk '{print $2}'`
endTime=$startTime
while read data
do
        curDay=`echo $data | awk '{print $1}'`
        if [[ $curDay != $prevDay ]]
        then
        echo $prevDay,$startTime,$endTime,$numOfRecords
                startTime=`echo $data | awk '{print $2}'`
                numOfRecords=1
        else
                numOfRecords=$((numOfRecords+1))
                endTime=`echo $data | awk '{print $2}'`
        fi
        prevDay=$curDay
done<log.txt
echo $prevDay,$startTime,$endTime,$numOfRecords


Last edited by Franklin52; 11-23-2014 at 09:17 AM.. Reason: Please use code tags, thanks
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Start and End times of background processes

Hi I'm running 4 jobs in the background and I need to write the start and end times to a log file. I know there's probably a simple way to do this but, I can't think of it. I've used nohup <script name> & but, that doesn't record the times. Is there a way to get the start and end times of a... (2 Replies)
Discussion started by: stonemonolith
2 Replies

2. Shell Programming and Scripting

extract a particular start and end pattern from a line

hi In the foll example the whole text in a single line.... i want to extract text from IPTel to RTCPBase.h. want to use this acrooss the whole file Updated: IPTel\platform\core\include\RTCPBase.h \main\MWS2051_Sablime_Int\1... (7 Replies)
Discussion started by: manish205
7 Replies

3. UNIX for Dummies Questions & Answers

Extract a specific number from an XML file based on the start and end tags

Hello People, I have the following contents in an XML file ........... ........... .......... ........... <Details = "Sample Details"> <Name>Bob</Name> <Age>34</Age> <Address>CA</Address> <ContactNumber>1234</ContactNumber> </Details> ........... ............. .............. (4 Replies)
Discussion started by: sushant172
4 Replies

4. Shell Programming and Scripting

can I specifiy the start and end times manually

Hi I have a ksh script which fetches data from a db using a number of .arc files and creates CSV files for them and puts them on the server. Question is, can I specifiy the start and stop times manually and run the script manually to fetch data for a certain period? # Get the current... (0 Replies)
Discussion started by: shajju
0 Replies

5. Shell Programming and Scripting

can I specifiy the start and end times manually

Hi I have a ksh script which fetches data from a db using a number of .arc files and creates CSV files for them and puts them on the server. Question is, how can I specifiy the start and stop times specifically so that data is fetched for a certain period? # Get the current time as the... (1 Reply)
Discussion started by: shajju
1 Replies

6. Shell Programming and Scripting

Extract data from an XML file & write into a CSV file

Hi All, I am having an XML tag like: <detail sim_ser_no_1="898407109001000090" imsi_1="452070001000090"> <security>ADM1=????</security> <security>PIN1=????</security> <security>PIN2=????</security> ... (2 Replies)
Discussion started by: ss_ss
2 Replies

7. Shell Programming and Scripting

Use grep sed or awk to extract string from log file and put into CSV

I'd like to copy strings from a log file and put them into a CSV. The strings could be on different line numbers, depending on size of log. Example Log File: File = foo.bat Date = 11/11/11 User = Foo Bar Size = 1024 ... CSV should look like: "foo.bat","11/11/11","Foo Bar","1024" (7 Replies)
Discussion started by: chipperuga
7 Replies

8. UNIX for Dummies Questions & Answers

extract regions of file based on start and end position

Hi, I have a file1 of many long sequences, each preceded by a unique header line. file2 is 3-columns list: headers name, start position, end position. I'd like to extract the sequence region of file1 specified in file2. Based on a post elsewhere, I found the code: awk... (2 Replies)
Discussion started by: pathunkathunk
2 Replies

9. Shell Programming and Scripting

Extract data from XML file and write in CSV file

Hi friend i have input as following XML file <?xml version="1.0"?> <Document xmlns="urn:iso:std:iso:20022:tech:xsd:camt.054.001.02"> <BkToCstmrDbtCdtNtfctn> <GrpHdr><MsgId>LBP-RDJ-TE000000-130042430010001001</MsgId><CreDtTm>2013-01-04T03:21:30</CreDtTm></GrpHdr>... (3 Replies)
Discussion started by: mohan sharma
3 Replies

10. Shell Programming and Scripting

Split a file by start and end row.

I have a file which looks something as following, I would like to split to several files, The start and end of each file is 'FILE' and end with 'ASCII... ' . At the same time for each file in the first column add 100 and also second column add 100 the rest of the column as it is , see example of... (2 Replies)
Discussion started by: tk2000
2 Replies
OGGTRANSCODE(1) 						   User Manuals 						   OGGTRANSCODE(1)

NAME
oggTranscode - transcodes ogg files in multiple ways SYNOPSIS
oggTranscode [options] inputfile.ogv outputfile.ogv DESCRIPTION
oggTranscode can resize an ogg file (ogg, oga or ogv) in multiple ways: It can change the video frame size, change datarate for the video and/or audio streams contained in the ogg file and it can also change the video frame rate or audio sample rate. Additionally, since version 0.8 oggTranscode can add any ogg comment and png-pictures with an alpha channel can be rendered into the video at any time period before and after the resizing process. oggTranscode was previously called oggResize. OPTIONS
-s Sets the size of the video frame. The size is given as <width>x<height>. At default, the video frame size keeps the same. Example: -s 320x240 -d Sets the datarate in byte per seconds for the video encoder (theora). This meant to be a upper threshold. So the file may be smaller than assumed. If not set, the datarate of the original stream is used. Example: -d 1024000 -D Sets the datarate in byte per seconds for the audio encoder (vorbis). If not set, the datarate of the original stream is used. Example: -D 64000 -f Sets the frame rate of the video with numinator and demoninator and is the pictures per second. If only one number is given, the denominator is set to 1. If not set, the framerate of the original video is used. Example: -f 25:2 -F Sets the sample frequency (sample rate) of the audio data in Hertz. If the sample frequency does not match the one with the original file, resamling is invoked. Example: -F 32000 -c Adds comments to the video (theora) stream. Comments are given by a pair of type and value in the form 'type=value'. More than one comment can be concatenated with a semicolon. It is recommended to use apostrophes as the command line may use the semicolon as a seperator. Example: -c 'AUTHOR=yorn;DATE=03.07.09' -C Adds comments to the audio (vorbis) stream. Comments are given by a pair of type and value in the form 'type=value'. More than one comment can be concatenated with a semicolon. It is recommended to use apostrophes as the command line may use the semicolon as a seperator. Example: -C 'AUTHOR=yorn;DATE=03.07.09' -q Specifies the quality for the resizing process. Values can be chosen between 1 (best quality, with slight bluring) and 6 (worst quality). The default value is 2. Example: -q1 -p This option is meant to help creating a preview of a film. The number given with this option defines the number of frames, that are omitted. E.g. if a film has 24 frames per second and -p24 is given, the newly created video shows the video 24 times faster as only every 24th frame is used. This option can be combined with the option -f to control the framerate. With both options nice video previews can be created. If -p is used, the audio stream is ignored. Example: -p 24 -a Adds a picture to the video frame before it is resized. The expression for the picture appearances: <picture1.png>[,<startTime>[,<endTime>[,s]]] default startTime is 0 default endTime is -1, which is the end of the stream duration default s ist not set. If s is set, the picture slides in smoothly. More than one picture can be included. To concatenate the expressions use the colon. If the appearance time overlap, the pictures are placed on one another, so the last picture is the uppest layer. Example: -a etwas.png,2,7,s:etwasneues.png,5,10 -A Adds a picture to the video frame after it is resized. The syntax follows the same expression as with option -a. EXAMPLE
oggTranscode -s320x240 -d512000 orig.ogv new.ogv Converts a the video orig.ogv to the video new.ogv with the new frame size 320x240. If there was an audio stream within the orig.ogv file, it is copied into the new file. oggTranscode -D64000 -F16000 -N1 orig.ogv new.ogv Converts only the audio stream of file orig.ogv to a sample rate of 16kHz, a datarate of 64 kBit/s and a mono channel. The video stream is copied as is. oggTranscode -s300x200 -D32000 -d1024000 -A etwas.png,2,7,s:etwasneues.png,5,10 orig.ogv new.ogv Converts the audio and video stream and adds the alpha channel picture etwas.png to the video from second 2 to second 7 with a smooth fade in and fade out. Additionally the alpha channel picture etwasneues.png is placed on top of the video frame from second 5 to second 10 without any fading. AUTHOR
Joern Seger <yorn at gmx dot net> SEE ALSO
oggCut(1), oggCat(1), oggJoin(1), oggSplit(1), oggSlideshow(1), oggThumb(1), oggSilence(1) Linux JAN 2010 OGGTRANSCODE(1)
All times are GMT -4. The time now is 04:11 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy