01-27-2009
Search the last instance of a string in a file
I have a big database log file which keepsgrowing daily. OS is HP UX. Here is a small part of it:
Tue Jan 27 04:03:22 2009
[2009/01/27@04:03:22.906-0500] : add session begin for mfgeb on /dev/pts/th.
[2009/01/27@04:03:22.909-0500] : Converting relative path to absolute path.
[2009/01/27@04:03:22.967-0500] : add session end.
Tue Jan 27 04:03:29 2009
[2009/01/27@04:03:29.345-0500] : list session begin for mfgeb on /dev/pts/th.
[2009/01/27@04:03:29.356-0500] : list session end.
Tue Jan 27 04:03:46 2009
[2009/01/27@04:03:46.262-0500] : add session begin for mfgeb on /dev/pts/tb.
[2009/01/27@04:03:46.331-0500] : add session end.
Tue Jan 27 04:03:49 2009
[2009/01/27@04:03:49.964-0500] : list session begin for mfgeb on /dev/pts/tb.
[2009/01/27@04:03:49.972-0500] : list session end.
Tue Jan 27 04:04:32 2009
[2009/01/27@04:04:32.147-0500] : add session begin for mfgeb on /dev/pts/tg.
[2009/01/27@04:04:32.182-0500] : add session end.
I need to search last instance of string "add session begin" in the file and then print date from that line. In the case here, it's 27th Jan 2009.
Someone please help.
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi,
I need to append string "Hi" to the beginning of the lines containing some specific string. How can I achieve that?
Please help.
Malay (1 Reply)
Discussion started by: malaymaru
1 Replies
2. Shell Programming and Scripting
Hello!
I need to delete one line in a file which matches one very precise instance of a string only. When searching the forum I unfortunately only found a solution which would delete each line on which a particular string occurs.
Let's assume I have a file composed of thousands of lines... (4 Replies)
Discussion started by: Black Sun
4 Replies
3. Shell Programming and Scripting
Hi
I'm trying to search for the last instance of the word 'cache' in a HTML file that I have downloaded from YouTube.
I'm using the following syntax, but an error is thrown when I try it.
grep -f "cache"
Also I wish to append the above grep command to the below so that the search for cache... (3 Replies)
Discussion started by: colmbell
3 Replies
4. Shell Programming and Scripting
Hi Guys,
I am trying to write a perl script to search a string "Name" in the file "FILE" and also want to create a new file and push the searched string Name line along with 10 lines following the same.
can anyone of you please let me know how to go about it ? (8 Replies)
Discussion started by: sukrish
8 Replies
5. Shell Programming and Scripting
I need to be able to search for a beginning line header, then use grep or something else to get the very next instance of a particular string, which will ALWAYS be in "Line5". What I have is some data that appears like this:
Line1
Line2
Line3
Line4
Line5
Line6
Line7
Line1
Line2
...... (4 Replies)
Discussion started by: Akilleez
4 Replies
6. Shell Programming and Scripting
I am having a text file which is having more than 200 lines.
EX:
001010122 12000 BIB 12000 11200 1200003
001010122 2000 AND 12000 11200 1200003
001010122 12000 KVB 12000 11200 1200003
In the above file i want to search for string KVB and add/replace... (1 Reply)
Discussion started by: suryanarayana
1 Replies
7. Shell Programming and Scripting
Dear All
I am having a text file which is having more than 200 lines.
EX:
001010122 12000 BIB 12000 11200 1200003
001010122 2000 AND 12000 11200 1200003
001010122 12000 KVB 12000 11200 1200003
In the above file i want to search for string KVB... (5 Replies)
Discussion started by: suryanarayana
5 Replies
8. Shell Programming and Scripting
Hi,
I want to do a sed (linux) or the alternative in PHP to insert a backslash in front of every occurrence of every forward slash
ex.
/archive/data/stanley
-->
\/archive\/data\/stanley
I appreciate it! (4 Replies)
Discussion started by: deadyetagain
4 Replies
9. Shell Programming and Scripting
Hi,
Need your help for this scripting issue I have. I am not really good at this, so seeking your help.
I have a file looking similar to this:
Hello, i am human and name=ABCD.
How are you?
Hello, i am human and name=PQRS.
I am good.
Hello, i am human and name=ABCD.
Good bye.
Hello, i... (12 Replies)
Discussion started by: royzlife
12 Replies
10. UNIX for Beginners Questions & Answers
I want to search a small string in a large string and find the locations of the string. For this I used grep "string" -ob <file name where the large string is stored>. Now this gives me the locations of that string. Now how do I store these locations in a text file.
Please use CODE tags as... (7 Replies)
Discussion started by: ANKIT ROY
7 Replies
LEARN ABOUT SUSE
date::manip::changes6
Date::Manip::Changes6(3) User Contributed Perl Documentation Date::Manip::Changes6(3)
NAME
Date::Manip::Changes6 - backward incompatible changes in Date::Manip 6.xx
SYNOPSIS
This describes all backwards incompatible changes made to the Date::Manip module starting at version 6.00.
DESCRIPTION
For the most part, Date::Manip has remained backward compatible at every release, but occasionally, a change is made which is backward
incompatible. These are documented here. Major changes are marked with asterisks.
6.05
%z format
In Date::Manip 5.xx, the %z format in UnixDate printed the offset in the form -0500. In 6.00, I changed that to -05:00:00, but this
broke RFC 822 compliance.
I've changed %z back to -0500, and introduced a new format (%N) which returns -05:00:00.
Incidentally, this is the LAST unused letter, so I am now going to have to either stop adding formats, or add some extended format
syntax. Not sure yet which, but this may involve a backwards incompatible change in the future.
BUGS AND QUESTIONS
Please refer to the Date::Manip::Problems documentation for information on submitting bug reports or questions to the author.
SEE ALSO
Date::Manip - main module documentation
LICENSE
This script is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
AUTHOR
Sullivan Beck (sbeck@cpan.org)
perl v5.12.1 2010-01-12 Date::Manip::Changes6(3)