Sponsored Content
Top Forums UNIX for Dummies Questions & Answers AIX UNIX - script on how to extract from log file with previous date Post 302929601 by RavinderSingh13 on Tuesday 23rd of December 2014 09:32:45 AM
Old 12-23-2014
Hello Kslew82,

Could you please try following, you can use 1 day ago in place of 5 days ago, let me know if this helps.
Code:
awk -vDATE="$(date -d"5 days ago" +%b" "%d)" '{if($1 OFS $2 ~ DATE){print $0}}'  Input_file

Output will be as follows.
Code:
Dec  18 07:25:09 aixtest3 local2:notice sudo:   klewis : TTY=unknown ;  PWD=/home/klewis ; USER=root ; COMMAND=/usr/bin/su - sybtest3
Dec 18 07:25:09 : klewis : TTY=unknown ; PWD=/home/klewis ; USER=root ;
Dec 18 07:25:41 aixtest3 local2:notice sudo:   klewis : TTY=unknown ; PWD=/home/klewis ; USER=root ; COMMAND=/usr/bin/smit
Dec 18 07:25:41 : klewis : TTY=unknown ; PWD=/home/klewis ; USER=root ;

Thanks,
R. Singh
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Capturing previous date in UNIX

Hi All, Hope you can help me out here...This is what I'm doing: % date '+%y.%m.%d' 05.03.05 How can I tweak this so that it gives me the PREVIOUS date, more specifically: 05.03.04 Hope you all can help. Thanks!!! Vince (3 Replies)
Discussion started by: tomeldan
3 Replies

2. HP-UX

previous DATE and operation IN HP/UNIX

It's possible make a add/Subtracttion a day with command DATE with a command similar a GNU/LINUX??? ex. date --set '10 minutes' ( return the same date minus 10 minutes) it's possible make this operation in HP/UX??? (1 Reply)
Discussion started by: ZINGARO
1 Replies

3. Shell Programming and Scripting

Specify a previous date as start date in shell script

Hi, I am trying to modify a script which accepts date in format dd/mm/yy. I am trying to modify the script so that it retrieves the date that was 15 days earlier from today as start date. Eg.if today is 05/09/2006, the script should retrieve 21/08/2006 as start date. Is there any script/code to... (2 Replies)
Discussion started by: ritzwan0
2 Replies

4. Shell Programming and Scripting

Extract date from log file

Hello All, I just need to extract the date portion from a apache log file I am able to do it using the chain of command - Logfile contents - First record - ========================== 197.130.211.240 - - "GET /jp/index.shtml HTTP/1.1" 200 24255... (4 Replies)
Discussion started by: jambesh
4 Replies

5. Shell Programming and Scripting

Extract data from log file from or after the specific date

Hi , I am having a script which will start a process and appends the process related logs to a log file. The log file writes logs with every line starting with date in the format of: date +"%Y %b %d %H:%M:%S". So, in the script, before I start the process, I am storing the date as DATE=`date +"%Y... (5 Replies)
Discussion started by: chiru_h
5 Replies

6. Shell Programming and Scripting

Extract info from log file and compute using time date stamp

Looking for a shell script or a simple perl script . I am new to scripting and not very good at it . I have 2 directories . One of them holds a text file with list of files in it and the second one is a daily log which shows the file completion time. I need to co-relate both and make a report. ... (0 Replies)
Discussion started by: breez_drew
0 Replies

7. Shell Programming and Scripting

Script to check file with previous date

Hi all,I need your help to create the script.I need a script to check the ZIP file at network location with yesterday date name. ZIP file creation date is current date, but name of the zip file is previous date. for example file name "20110216.zip" created today 201102017.I just want to return the... (1 Reply)
Discussion started by: deepaksingla
1 Replies

8. Shell Programming and Scripting

finding the previous day date and creating a file with date

Hi guys, I had a scenario... 1. I had to get the previous days date in yyyymmdd format 2. i had to create a file with Date inthe format yyyymmdd.txt format both are different thanks guys in advance.. (4 Replies)
Discussion started by: apple2685
4 Replies

9. UNIX for Dummies Questions & Answers

Extract date ranged data from log file

Hi, I am trying to extract lines of data within a log file on a Redhat 5 Linux system. eg I need all the lines with a particular username over the last 3 minutes. the log file may read like this, and I want a way to search all the lines extracting all the relevant lines over the last 3... (2 Replies)
Discussion started by: mantis100
2 Replies

10. Shell Programming and Scripting

How to get previous day from UNIX AIX?

Does anybody know how to get previous day on UNIX AIX? I tried TZ=XYZ+24 date '+%y%m%d' But it doesn't understand Thanks for contribution (6 Replies)
Discussion started by: digioleg54
6 Replies
PG_TTY(3)																 PG_TTY(3)

pg_tty - Return the TTY name associated with the connection

SYNOPSIS
string pg_tty ([resource $connection]) DESCRIPTION
pg_tty(3) returns the TTY name that server side debugging output is sent to on the given PostgreSQL $connection resource. Note pg_tty(3) is obsolete, since the server no longer pays attention to the TTY setting, but the function remains for backwards compati- bility. PARAMETERS
o $connection - PostgreSQL database connection resource. When $connection is not present, the default connection is used. The default connection is the last connection made by pg_connect(3) or pg_pconnect(3). RETURN VALUES
A string containing the debug TTY of the $connection, or FALSE on error. EXAMPLES
Example #1 pg_tty(3) example <?php $pgsql_conn = pg_connect("dbname=mark host=localhost"); if ($pgsql_conn) { print "Server debug TTY is: " . pg_tty($pgsql_conn) . "<br/> "; } else { print pg_last_error($pgsql_conn); exit; } ?> PHP Documentation Group PG_TTY(3)
All times are GMT -4. The time now is 03:44 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy