Sponsored Content
Full Discussion: time modification in script
Top Forums Shell Programming and Scripting time modification in script Post 302373306 by UniRock on Friday 20th of November 2009 02:21:19 AM
Old 11-20-2009
time modification in script

Hi All..

I have a file with a number of non-unique entries as below:


1243
01:42:29,567 --> 01:42:32,108
blah blah ....
blah blah ..

1244
01:42:32,709 --> 01:42:34,921
blah blah ....

1245
01:42:35,214 --> 01:42:36,533
blah blah ....
blah blah ..
blah blah ....
blah blah ..


Question is: How can I modify these timings in hh:mm:ss format. Say if I need to add/subtract 30 seconds throughout the file.

I tried to start with this:

cat title | grep "\-\-\>" | awk -F"-->" '{print $1 $2}'
00:07:59,651 00:08:00,379
00:08:34,417 00:08:35,518
00:08:36,892 00:08:38,094


cat title | grep "\-\-\>" | awk -F"-->" '{print $1 $2}'

##VARIABLES hour, minute, second:
hour1=`cat title | grep "\-\-\>" | awk -F"-->" '{print $1 $2}' | cut -c 1,2`
hour2=`cat title | grep "\-\-\>" | awk -F"-->" '{print $1 $2}' | cut -c 15,16`

min1=`cat title | grep "\-\-\>" | awk -F"-->" '{print $1 $2}' | cut -c 4,5`
min2=`cat title | grep "\-\-\>" | awk -F"-->" '{print $1 $2}' | cut -c 18,19`

sec1=`cat title | grep "\-\-\>" | awk -F"-->" '{print $1 $2}' | cut -c 7,8`
sec2=`cat title | grep "\-\-\>" | awk -F"-->" '{print $1 $2}' | cut -c 21,22`

secnew1=`expr $sec1 + 30`
echo $secnew1


But got ERROR ALL AROUND
.

AWK or SED preffered.
Or at least provide the logic.

Thanks a lot
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

File modification time

Does anyone know how to display the time with seconds of when a file was last modified. I can get hour & minutes but would also like seconds. --Running AIX (1 Reply)
Discussion started by: edog
1 Replies

2. UNIX for Advanced & Expert Users

Diff b/w modification & updated time

Hi All, What is the difference b/w last modification time and last updated time. Thanks Sweta (1 Reply)
Discussion started by: sweta
1 Replies

3. Shell Programming and Scripting

ls -e to find out File modification time in secs

Hi All, I would like to know the file modification time till seconds in Unix. So I tried ls -e and it worked fine. This Solaris 5.10 -rw-rw-r-- 1 test admin 22 Sep 12 11:01:37 2008 test_message But I am not able to run the same command in SOlaris 5.6 and also in AIX/HP Is there... (3 Replies)
Discussion started by: rahulkav
3 Replies

4. Shell Programming and Scripting

Archive Files over certain modification time

Environment is cygwin on Windows Server 2003 as I could not think how I would achieve this using Windows tools. What I want ot achieve is the following. I have a Directory D:\Data which contains further subfolders and files. I need to move "files" older than 6 months modification time to... (4 Replies)
Discussion started by: jelloir
4 Replies

5. Shell Programming and Scripting

File modification time comparison

Hi All, I have two files (given below) each exists under different paths. I want to compare the modification time stamp of file1.txt is lessthan the modification time of file2.txt. month1=`ls -l file1.txt | awk '{ print $6}'` date1=`ls -file1.txt | awk '{ print $7}'` time1=`ls... (1 Reply)
Discussion started by: Arunprasad
1 Replies

6. Shell Programming and Scripting

Find and symbolic link modification time

Hi, I have a directory made up of many symbolic links to folders multiple file systems. I want to return folders modified within the last 50 days, but find is using the link time rather than the target time. find . -type d -mtime -50 Is there a way to either: a) Make a symbolic link... (1 Reply)
Discussion started by: earls
1 Replies

7. UNIX for Dummies Questions & Answers

Need Modification Time of a file

Hi all, I need the modification time of a file on a particular day say 3 days before. I just don't want the last modification time. I need all the modification times on a particualar day. Is there anyway to do it? Kindly help. Could anyone tell me where the modification time is stored?... (1 Reply)
Discussion started by: vidhyab
1 Replies

8. Shell Programming and Scripting

Ls ignoring files from their modification time

Hi everyone, I'd like to know if is there a way to list files but ignoring some according to their modification time (or creation, access time, etc.) with the command 'ls' alone. I know the option -I exist, but it seems to only looking in the file name.. Thank you in advance for the... (8 Replies)
Discussion started by: Keyhaku
8 Replies

9. Shell Programming and Scripting

How to change modification time of file?

Explain it with proper e.g (4 Replies)
Discussion started by: sidpatil
4 Replies

10. OS X (Apple)

[OS X] Last modification time from shell in CCYYMMDDhhmm.ss format

This example shows last mtime from epoch $ stat -f %m somefile 752911565 But would like to see it like that: 199311100606.05 (2 Replies)
Discussion started by: Tribe
2 Replies
SIMPLEXML_IMPORT_DOM(3) 						 1						   SIMPLEXML_IMPORT_DOM(3)

simplexml_import_dom - Get a SimpleXMLElementobject from a DOM node.

SYNOPSIS
SimpleXMLElement simplexml_import_dom (DOMNode $node, [string $class_name = "SimpleXMLElement"]) DESCRIPTION
This function takes a node of a DOM document and makes it into a SimpleXML node. This new object can then be used as a native SimpleXML element. PARAMETERS
o $node - A DOM Element node o $class_name - You may use this optional parameter so that simplexml_import_dom(3) will return an object of the specified class. That class should extend the SimpleXMLElement class. RETURN VALUES
Returns a SimpleXMLElement or FALSE on failure. Warning This function may return Boolean FALSE, but may also return a non-Boolean value which evaluates to FALSE. Please read the section on Booleans for more information. Use the === operator for testing the return value of this function. EXAMPLES
Example #1 Importing DOM <?php $dom = new DOMDocument; $dom->loadXML('<books><book><title>blah</title></book></books>'); if (!$dom) { echo 'Error while parsing the document'; exit; } $s = simplexml_import_dom($dom); echo $s->book[0]->title; ?> The above example will output: blah SEE ALSO
dom_import_simplexml(3), "Basic SimpleXML usage". PHP Documentation Group SIMPLEXML_IMPORT_DOM(3)
All times are GMT -4. The time now is 07:27 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy