Sponsored Content
Full Discussion: How to Compare timestamp
Top Forums Shell Programming and Scripting How to Compare timestamp Post 302596415 by Corona688 on Tuesday 7th of February 2012 10:01:06 AM
Old 02-07-2012
Quote:
Originally Posted by vsachan
Thanks Corona...
But it is giving error...

gunzip -c ABCDEF.gz | awk -F, -v T1="20:00:00" -v T2="20:01:00" '{if(T1>=$2)&&(T2<=$2) print $0'


error is:
Syntax Error The source line is 1.
The error context is
>>> {if(T1>=$2)&& <<<
awk: 0602-502 The statement cannot be correctly parsed. The source line is 1.
Try the code I actually gave you instead of rewriting it into something broken.

The version you wrote is very redundant( X { print $0 } is equivalent to just X ) and missing tons of important brackets -- i.e. you forgot the ending }, and didn't put the if-statement in its own ().
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

how to compare the timestamp of 2 files

i want to compare the timestamp of the 2 file.. please let me know how we can achive this.. (2 Replies)
Discussion started by: mail2sant
2 Replies

2. AIX

how to grep and compare timestamp in a file with the current date

I want to read a log file from a particular location.In the logfile , lines contains timestamp.I need to compare the timestamp in the logfile with the current date.If the timpestamp in the log file is less than 4 hours then i need to read the file from that location.Below is the file format.Please... (1 Reply)
Discussion started by: achu
1 Replies

3. AIX

how to grep and compare timestamp in a file with the current date

I want to read a log file from a particular location.In the log file each line starts with timestamp.I need to compare the timestamp in the logfile with the current date.If the timpestamp in the log file is less than 4 hours then i need to read the file from that location.Below is the file... (1 Reply)
Discussion started by: achu
1 Replies

4. Shell Programming and Scripting

Compare file timestamp with current date. Diff must be 1 hour.

Hello, I've created the script below to compare the content of two files with a delay of an hour. After an hour, the lines that exist in both files, will be printed and executed. The script now uses a counter to countdown 50 minutes. But what I would prefer is to check the file timestamp of... (3 Replies)
Discussion started by: taipan
3 Replies

5. Shell Programming and Scripting

Compare current time to timestamp on a file

I'm trying to compare 2 dates between current time and the timestamp on a file. The date format is mmdd Both return Apr 1 but when using if statement line 11: Apr 1: command not found error is returned #!/bin/sh log="DateLog" Current_Date=`date +%b%e` Filepmdate=`ls -l /file.txt |... (1 Reply)
Discussion started by: cillmor
1 Replies

6. Shell Programming and Scripting

Getting a relative timestamp from timestamp stored in a file

Hi, I've a file in the following format 1999-APR-8 17:31:06 1500 3 45 1999-APR-8 17:31:15 1500 3 45 1999-APR-8 17:31:25 1500 3 45 1999-APR-8 17:31:30 1500 3 45 1999-APR-8 17:31:55 1500 3 45 1999-APR-8 17:32:06 1500 3 ... (1 Reply)
Discussion started by: vaibhavkorde
1 Replies

7. UNIX for Dummies Questions & Answers

How to compare a file by its timestamp and store in a different location whenever timestamp changes?

Hi All, I am new to unix programming. I am trying for a requirement and the requirement goes like this..... I have a test folder. Which tracks log files. After certain time, the log file is getting overwritten by another file (randomly as the time interval is not periodic). I need to preserve... (2 Replies)
Discussion started by: mailsara
2 Replies

8. Shell Programming and Scripting

To check timestamp in logfile and display lines upto 3 hours before current timestamp

Hi Friends, I have the following logfile. Currently time in india is 07/31/2014 12:33:34 and i have the following content in logfile. I want to display only those entries which contain string 'Exception' within last 3 hours. In this case, it would be the last line only I can get the... (12 Replies)
Discussion started by: srkmish
12 Replies

9. Shell Programming and Scripting

AIX : Need to convert UNIX Timestamp to normal timestamp

Hello , I am working on AIX. I have to convert Unix timestamp to normal timestamp. Below is the file. The Unix timestamp will always be preceded by EFFECTIVE_TIME as first field as shown and there could be multiple EFFECTIVE_TIME in the file : 3.txt Contents of... (6 Replies)
Discussion started by: rahul2662
6 Replies

10. Shell Programming and Scripting

Grep lines between last hour timestamp and current timestamp

So basically I have a log file and each line in this log file starts with a timestamp: MON DD HH:MM:SS SEP 15 07:30:01 I need to grep all the lines between last hour timestamp and current timestamp. Then these lines will be moved to a tmp file from which I will grep for particular strings. ... (1 Reply)
Discussion started by: nms
1 Replies
acctprc(8)						      System Manager's Manual							acctprc(8)

NAME
acctprc1, acctprc2, accton - Perform process-accounting procedures SYNOPSIS
acctprc1 [InFile] acctprc2 accton [OutFile] DESCRIPTION
The three acctprc commands, acctprc1, acctprc2, and accton, are used in the runacct shell procedure to produce process-accounting reports. acctprc1 [InFile] The acctprc1 command is used to read records from standard input that are in a format defined by the acct structure in the /usr/include/sys/acct.h header file. This process adds the login names that correspond to user IDs, and then writes corresponding ASCII records to standard output. For each process, the record format includes the following seven unheaded columns: The user ID column includes both traditional and assigned user identification numbers listed in the /etc/passwd file. The login name is the one used for the user ID in the /etc/passwd file. The number of seconds the process consumed when executed during prime-time hours. Prime-time and nonprime-time hours are defined in the /usr/sbin/acct/holidays file. The number of seconds the process consumed when executed during nonprime-time hours. Total number of characters transferred. Total number of blocks read and written. Mean memory size (in kilobyte units). When specified, InFile contains a list of login sessions in a format defined by the utmp structure in the /usr/include/utmp.h header file. The login session records are sorted according to user ID and login name. When InFile is not specified, acctprc1 gets login names from the password file /etc/passwd. The information in InFile is used to distinguish different login names that share the same user ID. acctprc2 The acctprc2 command reads, from standard input, the records written by acctprc1, summarizes them according to user ID and name, and writes sorted summaries to standard output as total accounting records in the tacct format (see the acctmerg command). accton [OutFile] When no parameters are specified with the accton command, account processing is turned off. When you specify an existing OutFile file, process accounting is turned on, and the kernel adds records to that file. You must specify an Outfile to start process accounting. Many shell script procedures expect the file name /var/adm/pacct, the standard process-accounting file. EXAMPLES
To add a user name to each process-accounting record in a binary file and then write these modified binary-file records to an ASCII file named out.file, enter the following line to an accounting shell script: /usr/sbin/acct/acctprc1 < /var/adm/pacct >out.file A user name is added to each record. The raw data in the pacct file is converted to ASCII and added to file out.file. To produce a total binary accounting record of the ASCII output file out.file produced in example 1, enter the following line to an accounting shell script: /usr/sbin/acct/acctprc2 < out.file > /var/adm/acct/nite/daytacct The resulting binary total accounting file, written in the acct format, contains records sorted by user ID. This sorted user ID file, is usually merged with other total accounting records when an acctmerg command is processed to produce a daily summary accounting record called /var/adm/acct/sum/daytacct. To turn on process accounting, enter: /usr/sbin/acct/accton /var/adm/pacct To turn off process accounting, enter: /usr/sbin/acct/accton FILES
Specifies the command path. Specifies the command path. Specifies the command path. RELATED INFORMATION
Commands: acct(8), acctcms(8), acctmerg(8), runacct(8) Functions: acct(2) delim off acctprc(8)
All times are GMT -4. The time now is 04:57 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy