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::MUC(3pm)				User Contributed Perl Documentation			     AnyEvent::XMPP::Ext::MUC(3pm)

NAME
AnyEvent::XMPP::Ext::MUC - Implements XEP-0045: Multi-User Chat SYNOPSIS
my $con = AnyEvent::XMPP::Connection->new (...); $con->add_extension (my $disco = AnyEvent::XMPP::Ext::Disco->new); $con->add_extension (my $muc = AnyEvent::XMPP::Ext::MUC->new (disco => $disco)); ... DESCRIPTION
This module handles multi user chats and provides new events to catch multi user chat messages. It intercepts messages from the connection so they don't interfere with your other callbacks on the connection. This extension requires the AnyEvent::XMPP::Ext::Disco extension for service discovery. METHODS
new This is the constructor for a MUC extension object. It takes no further arguments. is_conference ($con, $jid, $cb) TODO is_room ($con, $jid, $cb) This method sends a information discovery to the $jid, via the connection $con. $cb is called when the information arrives or with an error after the usual IQ timeout. When the $jid was a room $cb is called with the first argument being a AnyEvent::XMPP::Ext::MUC::RoomInfo object. If the destination wasn't reachable, the room doesn't exist or some other error happened the first argument will be undefined and the second a AnyEvent::XMPP::Error::IQ object. join_room ($con, $jid, $nick, %args) This method joins a room. $con should be the AnyEvent::XMPP::IM::Connection object that is to be used to send the necessary stanzas. $jid should be the bare JID of the room. $nick should be your desired nickname in the room. When you successfully entered the room a "enter" event is emitted. In case you created the room, and it is locked, a "locked" event is emitted. Please look in the "EVENTS" section below for more details about how to handle "locked" rooms. (You won't have to care about locked rooms if you didn't disable the "create_instant" flag in %args). If an error occurred and we couldn't join the room, the first two arguments are undef and the third is a AnyEvent::XMPP::Error::MUC object signalling the error. %args hash can contain one of the following keys: timeout => $timeout_in_secs This is the timeout for joining the room. The default timeout is 60 seconds if the timeout is not specified. history => {} Manage MUC-history from XEP-0045 (7.1.16) Hash can contain of the following keys: "chars", "stanzas", "seconds" Example: history => {chars => 0} # don't load history history => {stanzas => 3} # load last 3 history elements history => {seconds => 300, chars => 500} # load history in last 5 minutes, but max 500 characters TODO: add "since" attributes create_instant => $bool If you set $bool to a true value we try to establish an instant room on joining if it doesn't already exist. XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX The default for this flag is true! So if you want to create an reserved room with custom creation in the beginning you have to pass a false value as $bool. PLEASE NOTE: If you set $bool to a false value you have to check the "did_create_room" status flag on your own instance of AnyEvent::XMPP::Ext::MUC::User (provided as the second argument to the callback) to see whether you need to finish room creation! If you don't do this the room may stay LOCKED for ever. See also the "make_instant" and "request_configuration" methods of AnyEvent::XMPP::Ext::MUC. password => $password The password for the room. nickcollision_cb => $cb If the join to the room results in a nickname collision the $cb will be called with the nickname that collided and the return value will be used as alternate nickname and the join is retried. This function is called everytime the nickname collides on join, so you should take care of possible endless retries. get_room ($con, $jid) This returns the AnyEvent::XMPP::Ext::MUC::Room object for the bare part of the $jid if we are joining or have joined such a room. If we are not joined undef is returned. get_rooms ($con) Returns a list of AnyEvent::XMPP::Ext::MUC::Room objects for the connection $con. EVENTS
These are the events that are issued by this MUC extension: $room is the AnyEvent::XMPP::Ext::MUC::Room object which the event belongs to. message => $room, $msg, $is_echo This event is emitted when a message was received from the room. $msg is a AnyEvent::XMPP::Ext::MUC::Message object and $is_echo is true if the message is an echo. NOTE: Please note that some conferences send messages already before you have finished joining a room. That means that you might already get a "message" event for a room that you haven't got an "enter" for event yet. That means that methods like "get_me" might return undef. subject_change => $room, $msg, $is_echo This event is emitted when a user changes the room subject. $msg is a AnyEvent::XMPP::Ext::MUC::Message object and $is_echo is true if the message is an echo. The room subject is the subject of that $msg. subject_change_error => $room, $error If you weren't allowed to change the subject or some other error occurred you will receive this event. $error is a AnyEvent::XMPP::Error::MUC object. error => $room, $error This event is emitted when any error occurred. $error is a AnyEvent::XMPP::Error::MUC object. join_error => $room, $error This event is emitted when a error occurred when joining a room. $error is a AnyEvent::XMPP::Error::MUC object. locked => $room This event is emitted when you disabled the 'create_instant' flag when calling "join_room". It means that you just created a new room, which is locked. You need to configure it before it is unlocked and others can enter. Please consult the methods "make_instant", "request_configuration" and "send_configuration" of AnyEvent::XMPP::Ext::MUC::Room for more information about how to configure a room. NOTE: You won't get another event when you finished configuring the room, so you maybe want to call this on the "AnyEvent::XMPP::Ext::MUC" object when you finished configuring the room successfully: $muc->event (enter => $room, $room->get_me); That could be helpful if you want to place some generic stuff in your "enter" event handlers. NOTE2: If you didn't disable the "create_instant" flag of "join_room" you won't have to care about a "locked" event, as everything will be internally handled for you and you will get an "enter" event if the room is finally setted up. enter => $room, $user This event is emitted when we successfully joined the room. $user is a AnyEvent::XMPP::Ext::MUC::User object which is the user handle for ourself. join => $room, $user This event is emitted when a new user joins the room. $user is the AnyEvent::XMPP::Ext::MUC::User object of that user. nick_change => $room, $user, $oldnick, $newnick This event is emitted when a user changed his nickname. $user is the AnyEvent::XMPP::Ext::MUC::User object of that user. $oldnick is the old nickname and $newnick is the new nickname. presence => $room, $user This event is emitted when a user changes it's presence status (eg. affiliation or role, or away status). $user is the AnyEvent::XMPP::Ext::MUC::User object of that user. part => $room, $user This event is emitted when a user leaves the channel. $user is the AnyEvent::XMPP::Ext::MUC::User of that user, but please note that you shouldn't send any messages to this user anymore. leave => $room, $user This event is emitted when we leave the room. $user is your AnyEvent::XMPP::Ext::MUC::User handle. AUTHOR
Robin Redeker, "<elmex at ta-sa.org>", JID: "<elmex at jabber.org>" COPYRIGHT &; LICENSE Copyright 2007, 2008 Robin Redeker, all rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.14.2 2012-01-23 AnyEvent::XMPP::Ext::MUC(3pm)
All times are GMT -4. The time now is 04:14 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy