Sponsored Content
Top Forums Shell Programming and Scripting How to script to find the newer date in a text file? Post 302342711 by boolean2222 on Monday 10th of August 2009 01:29:30 PM
Old 08-10-2009
Bug How to script to find the newer date in a text file?

Hi,
I have a text file, foo.txt, it looks something like below. In the file there is a line that gives the date in the form of: Mon Jun 15 11:09:31 2008. I need to find which date is the newest and then store certain details of that list data to another file. So, in this sample text file, I need the data from add, mob and tele from List #1 into another file called foo1.txt because List # 1 is the newest and those three attributes are the only ones I ever need.


foo.txt:
Code:
List  #            Name
-----           ------------------
4                george
6                george
5                george
1                george

List  #: 4
Name:        blah1
Tele:           blah2
Mob:          blah3
Add:          blah4
Ext. 1:       blah5
Ext. 2:       blah6
Ext. 3:       blah7
Date:         Mon Jun 15 11:09:31 2008

List #: 6
Name:        blah1
Tele:           blah2
Mob:          blah3
Add:          blah4
Ext. 1:       blah5
Ext. 2:       blah6
Ext. 3:       blah7
Date:         Mon Jun 15 11:10:31 2008

List #: 5
Name:        blah1
Tele:           blah2
Mob:          blah3
Add:          blah4
Ext. 1:       blah5
Ext. 2:       blah6
Ext. 3:       blah7
Date:         Mon Jun 15 11:11:31 2008

List #: 1
Name:        blah1
Tele:           blah2
Mob:          blah3
Add:          blah4
Ext. 1:       blah5
Ext. 2:       blah6
Ext. 3:       blah7
Date:         Mon Jun 15 10:09:31 2008

 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Find files newer than...

Is there a way to use the find command to locate files newer than a specific date? Thanks! --Alex (4 Replies)
Discussion started by: vertigo23
4 Replies

2. Shell Programming and Scripting

Problem with find ! -newer

Hi, I would like to find if a file called test.log is older than 10 min. So i wrote : #!/usr/bin/ksh FICLOG="/home/uuu/result_test.log" FIC="/home/uuu/test.log" touch -t `perl -e 'use POSIX qw(strftime); printf("%s\n",strftime("%m%d%H%M",localtime(time-3600*0.17)));'`... (3 Replies)
Discussion started by: dbfree
3 Replies

3. UNIX for Advanced & Expert Users

find file with date and recursive search for a text

Hey Guyz I have a requirement something like this.. a part of file name, date of modification of that file and a text is entered as input. like Date : 080206 (MMDDYY format.) filename : hotel_rates text : Jim now the file hotel_rates.ZZZ.123 (creation date is Aug 02 2006) should be... (10 Replies)
Discussion started by: rosh0623
10 Replies

4. Solaris

To copy the files newer than specific date

Dear all, Can you help me in copying files newer than speciifc date Thanks in advance, Rajesh (3 Replies)
Discussion started by: RAJESHKANNA
3 Replies

5. UNIX for Advanced & Expert Users

find -cmin or fin -newer

I am running SUSE/8 and SUSE/9 on a high end server (4 CPU, 8G RAM etc) I have a huge directory structure with over 4million files in it. I have find the files that are modified (created, modified, renamed etc etc) in the last 10 minutes periodically. I have tried "find -cmin -10" and "find... (2 Replies)
Discussion started by: xxxyyyy
2 Replies

6. Shell Programming and Scripting

Problems with find's -newer Flag

I am writing a script that looks in a reports directory, copies a specified script to a working folder, copies some data files into the working folder, runs the report, zips the new files, then uploads them. Right now to determine what files to zip (as I don't know how many report files there... (6 Replies)
Discussion started by: droppedonjapan
6 Replies

7. Shell Programming and Scripting

how to find a file then overwrite with a newer version

This should be a simple script, but can't find one with google search. I just need to find the file that is in many directories, then overwrite that file with a newer version i.e. find file.jar then overwrite with /root/file.jar All I get in searches is substitute text with new test inside... (1 Reply)
Discussion started by: haircat
1 Replies

8. UNIX for Dummies Questions & Answers

Find files newer than x days

We had an arrant rsync run and started copying over new files from one system to another. Although this is what we will want to do at some point, for now, we want to maintain the system as it was a few days ago. I am looking for a script that will find files that are newer than x days. ... (5 Replies)
Discussion started by: Leyva62
5 Replies

9. Shell Programming and Scripting

Need a unix script to convert date into Julian format in a text file

The 6th & 7th column of the text files represents date & time. I need this to be converted in julian format using command "date +%s -d <date>". I know the command, but dont know how to use it on the script 0 dbclstr-b IXT_Web Memphis_Prod_SQL_Full Memphis-Prod-SQL-Full-Application-Backup... (4 Replies)
Discussion started by: ajiwww
4 Replies

10. Shell Programming and Scripting

Perl script, replace file with newer file

Hello, Can you please help me one this: I have two servers: Server A and server B. Every day on 03.00AM in only one on these two servers (randomly)is generated one file, lets say file.txt. I want to copy this file also to the other server. I want to create a perl script that does... (2 Replies)
Discussion started by: arrals_vl
2 Replies
AnyEvent::XMPP::Ext::OOB(3pm)				User Contributed Perl Documentation			     AnyEvent::XMPP::Ext::OOB(3pm)

NAME
AnyEvent::XMPP::Ext::OOB - XEP-0066 Out of Band Data SYNOPSIS
my $con = AnyEvent::XMPP::Connection->new (...); $con->add_extension (my $disco = AnyEvent::XMPP::Ext::Disco->new); $con->add_extension (my $oob = AnyEvent::XMPP::Ext::OOB->new); $disco->enable_feature ($oob->disco_feature); $oob->reg_cb (oob_recv => sub { my ($oob, $con, $node, $url) = @_; if (got ($url)) { $oob->reply_success ($con, $node); } else { $oob->reply_failure ($con, $node, 'not-found'); } }); $oob->send_url ( $con, 'someonewho@wants.an.url.com', "http://nakedgirls.com/marie_021.jpg", "Yaww!!! Hot like SUN!", sub { my ($error) = @_; if ($error) { # then error } else { # everything fine } } ) DESCRIPTION
This module provides a helper abstraction for handling out of band data as specified in XEP-0066. The object that is generated handles out of band data requests to and from others. There is are also some utility function defined to get for example the oob info from an XML element: FUNCTIONS
url_from_node ($node) This function extracts the URL and optionally a description field from the XML element in $node (which must be a AnyEvent::XMPP::Node). $node must be the XML node which contains the <url> and optionally <desc> element (which is eg. a <x xmlns='jabber:x:oob'> element)! (This method searches both, the jabber:x:oob and jabber:iq:oob namespaces for the <url> and <desc> elements). It returns a hash reference which should have following structure: { url => "http://someurl.org/mycoolparty.jpg", desc => "That was a party!", } If nothing was found this method returns nothing (undef). METHODS
new () This is the constructor, it takes no further arguments. reply_success ($con, $node) This method replies to the sender of the oob that the URL was retrieved successfully. $con and $node are the $con and $node arguments of the "oob_recv" event you want to reply to. reply_failure ($con, $node, $type) This method replies to the sender that either the transfer was rejected or it was not fount. If the transfer was rejectes you have to set $type to 'reject', otherwise $type must be 'not-found'. $con and $node are the $con and $node arguments of the "oob_recv" event you want to reply to. send_url ($con, $jid, $url, $desc, $cb) This method sends a out of band file transfer request to $jid. $url is the URL that the otherone has to download. $desc is an optional description string (human readable) for the file pointed at by the url and can be undef when you don't want to transmit any description. $cb is a callback that will be called once the transfer is successful. The first argument to the callback will either be undef in case of success or 'reject' when the other side rejected the file or 'not-found' if the other side was unable to download the file. EVENTS
These events can be registered to whith "reg_cb": oob_recv => $con, $node, $url This event is generated whenever someone wants to send you a out of band data file. $url is a hash reference like it's returned by "url_from_node". $con is the AnyEvent::XMPP::Connection (Or AnyEvent::XMPP::IM::Connection) the data was received from. $node is the AnyEvent::XMPP::Node of the IQ request, you can get the senders JID from the 'from' attribute of it. If you fetched the file successfully you have to call "reply_success". If you want to reject the file or couldn't get it call "reply_failure". perl v5.14.2 2012-01-23 AnyEvent::XMPP::Ext::OOB(3pm)
All times are GMT -4. The time now is 10:33 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy