Sponsored Content
Top Forums Shell Programming and Scripting help to retrive data from log file Post 302078658 by Hitori on Monday 3rd of July 2006 04:51:55 PM
Old 07-03-2006
perl

Implying that dates were written in same format:

Code:
$ cat 1.pl
#!/usr/bin/perl -w

open (INPUT, "< logfile");

my $last = '', @to_print = ();
while (<INPUT>) {

    push @to_print, $_;
    if (/^\*{3}/) {
        s/\*//g;
        @to_print = ($to_print[$#to_print]) if $last ne $_;
        $last = $_;
    }
}

for (@to_print) {
    print $_;
}

Code:
$ cat logfile
*****************Thu Jun 28 20:06:28 BST 2006**************************************
Generation Number : 20062231
Generation Date : 20060629
There are no detail records
*****************Thu Jun 29 23:46:38 BST 2006**************************************
Generation Number : 20062231
Generation Date : 20060629
There are no detail records
*****************Fri Jun 30 00:01:19 BST 2006**************************************
Generation Number : 20062237
Generation Date : 20060629
There are no detail records
*****************Fri Jun 30 00:01:19 BST 2006**************************************
Generation Number : 20062237
Generation Date : 20060630
There are no detail records

Code:
$ ./1.pl
*****************Fri Jun 30 00:01:19 BST 2006**************************************
Generation Number : 20062237
Generation Date : 20060629
There are no detail records
*****************Fri Jun 30 00:01:19 BST 2006**************************************
Generation Number : 20062237
Generation Date : 20060630
There are no detail records

 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Retrive deleted file's info

I have shell script which reads files, stores its data into Oracle and then deletes tht file. now i want to know creation date and time of deleted files. can we do this? if yes then how? (4 Replies)
Discussion started by: asmita
4 Replies

2. Shell Programming and Scripting

to retrive data that appear only once in a file.

hi, I need to get the list of functions that are used more than once in a file list. Thanks in advance (1 Reply)
Discussion started by: anibu
1 Replies

3. Shell Programming and Scripting

retrive lines from a file using AWK command

Dear friends, please tell me how to get some required lines from a file and write to another file using AWK command. i.e., if a file contains, abcdefghigk 12345 lmnopqrstuv 678910 wxyz please tell me how to get lines(line count is always 2 and it's contineous) mentioned in blue... (1 Reply)
Discussion started by: swamymns
1 Replies

4. Shell Programming and Scripting

retrive value from a file

hi i am new to shell scripting i have a properties file like hs=abc hs1=def hs2=ghi now i want to retrive each value and assign it to a variable like var1 = abc please help (7 Replies)
Discussion started by: satish@123
7 Replies

5. Shell Programming and Scripting

Retrive the value returned by a command excuted in a remote server using ssh

Hello Everybody, I'm facing a weird problem with the awk command. I try to retrieve in a variable the value returned by a simple ls command. ls /export/home/tmp |tail -1 return a good value (the name of the . But When I try to execute the same command in a remote server using ssh as... (2 Replies)
Discussion started by: Jabarod
2 Replies

6. Shell Programming and Scripting

Range of data from a log file .

I am having a log file in which i need a range of data from specific date range. $cat my.log Jan 07 15:39:03 N/A _M_LocalDirectory listFiles(): listing files from dir Jan 07 15:39:03 N/A _w_fm_log:_f_Push() _w_fm_log_export_ftppush(): Files f Jan 07 05:58:35 N/A _w_fm_log_autoexport ... (6 Replies)
Discussion started by: posix
6 Replies

7. UNIX for Dummies Questions & Answers

make ls retrive ordered list of elements

Hello friends!! I have a question regarding the use of ls in unix. I have a folder with files: t1.txt t2.txt t3.txt t4.txt ... t10.txt When I make an ls I always get: t10.txt t1.txt t2.txt t3.txt .. t9.txt (2 Replies)
Discussion started by: SaktiPhoenix
2 Replies

8. UNIX for Dummies Questions & Answers

How to retrive data from DB(Aqua studio) in CVS format using UNIX script?

I am using aqua studio DB. I need to retrive the data from my database using uxin script in .csv format. i am using select query along with the joins. my o/p in the DB is of the below format. Cycle IDCycle StatusRecord 98N-0000ACV23-3636FCliet Level (Af)Success1689393HF-J7879-09090RCliet Level... (1 Reply)
Discussion started by: Mugivz
1 Replies

9. Shell Programming and Scripting

Data sorting out from log file

I have a logfile looks like this: Received request of type I need two write out every line to a new file if contains to a file called the SID name, like 187175558_xyz.txt Thanks for helping! ---------- Post updated at 08:11 AM ---------- Previous update was at 08:10 AM ---------- I... (7 Replies)
Discussion started by: batka
7 Replies

10. Shell Programming and Scripting

Extract data from a log file and put it in a file

Hi, I would like to seek your help for a script that will extract data from log file and put it in a file. Sample log file 2018-10-23 12:33:21 AI ERROR -- tpid: SAMPLE_TH account: 123456789 aiSessionNumber: 660640464 mapName: xxx to yyy errorDesc: Translation Error:ErrorNumber : 993 ... (2 Replies)
Discussion started by: neverwinter112
2 Replies
UTMPX(5)						      BSD File Formats Manual							  UTMPX(5)

NAME
utmpx, wtmpx, lastlogx -- user accounting database SYNOPSIS
#include <utmpx.h> DESCRIPTION
In contrast to utmp and wtmp, the extended databases in utmpx and wtmpx reserve more space for logging hostnames, and also information on a process' ID, termination signal and exit status. The <utmpx.h> header defines the structures and functions for logging user. Currently logged in users are tracked in /var/run/utmpx, a list of all logins and logouts, as well as all shutdowns, reboots and date changes, is kept in /var/log/wtmpx, and the last login of each user is noted in /var/log/lastlogx. The interface to the utmpx file is described in getutxent(3). The wtmpx file can grow rapidly on busy systems, and is normally rotated with newsyslog(8). In the event of a date change, a shutdown, or a reboot, the following items are logged in the wtmpx file: date The system time has been manually or automatically updated by date(1). The command name date is recorded in the field ut_name. In the field ut_line, the character '|' indicates the time prior to the change, and the character '{' indicates the new time. reboot shutdown A system reboot or shutdown has been initiated. The character '~' is placed in the field ut_line, and reboot or shutdown in the field ut_name (see shutdown(8) and reboot(8)), using logwtmpx(3). FILES
/var/run/utmpx The utmpx file. /var/log/wtmpx The wtmpx file. /var/log/lastlogx The lastlogx file. SEE ALSO
last(1), login(1), rwho(1), w(1), who(1), endutxent(3), logwtmpx(3), utmp(5), ac(8), init(8), newsyslog(8), reboot(8) BSD
January 31, 2007 BSD
All times are GMT -4. The time now is 01:58 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy