Sponsored Content
Top Forums Shell Programming and Scripting AIX : Need to convert UNIX Timestamp to normal timestamp Post 302959145 by rahul2662 on Thursday 29th of October 2015 09:43:49 AM
Old 10-29-2015
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

Code:
Contents of /usr/openv/netbackup/db/class/PRDEWQ_OS/info :
\n
ACTIVE 0
EFFECTIVE_TIME 1279635438
\n
Contents of /usr/openv/netbackup/db/class/PRDEWQ_OS/schedule/Full/days :
\n
0 0 39600
1 0 0
2 0 0
3 0 0
4 0 0
5 0 0
6 0 0
\n
Contents of /usr/openv/netbackup/db/class/PRDEWQ_OS/schedule/Full/info :
\n
\n
Contents of /usr/openv/netbackup/db/class/PRDEWQ_OS/schedule/Incremental/days :
\n
0 0 0
1 0 25200
2 0 25200
3 0 25200
4 0 25200
5 0 25200
6 0 25200
\n
Contents of /usr/openv/netbackup/db/class/PRDEWQ_OS/schedule/Incremental/info :
\n
\n


I ran the following but it failed :

Code:
awk '/EFFECTIVE_TIME/ { printf "%s %s\n", $1,$(perl -le 'print scalar localtime(shift)' $2); next} 1' 3.txt

-bash: syntax error near unexpected token `('

Could someone please help.

Thanks
Rahul
 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

AIX/awk date to unix timestamp

Hello, I am inside a awk script on AIX, I am feeding to awk ls -luNR i need to convert ls -u time format "month day h:m/yr" to Unix epoch time, POSIX time, or aka unix timestamp I do not have strftime funk in my awk, and i have to do this fast meaning that I cannot do a system call in the... (1 Reply)
Discussion started by: nullwhat
1 Replies

2. Shell Programming and Scripting

Convert Unix Timestame to real timestamp

Hello, Did anyone know how to use script (e.g. perl) to conver Unix Timestame to real timestame in GMT+8 ? 1245900787 file:/tmp/a/Test/.txt.swp has created 1245900988 file:/tmp/a/Test/.txt.swp has changed Thu, 25 Jun 2009 11:33:07 GMT+8 file:/tmp/a/Test/.txt.swp has created Thu, 25 Jun... (4 Replies)
Discussion started by: happyday
4 Replies

3. Shell Programming and Scripting

To convert a date(in string format) to unix timestamp

Hi All, I have a string like below. "Mar 31 2009" . I want to convert this to unix time . Also please let me know how to find the unix time for the above string minus one day. For Eg. if i have string "Mar 31 2009" i want to find the unix time stamp of "Mar 30 2009". Thanks in advance,... (11 Replies)
Discussion started by: girish.raos
11 Replies

4. AIX

Convert unix timestamp to year month day format ?

Hello, How do I convert unix timestamp value to 'normal' date format - to get year month and day values ? Looks like it's easy to do using GNU date (linux systems). But how do I do tthis on AIX ? I don't want to write C program, any ways to do that using unix shells ? thanks (1 Reply)
Discussion started by: vilius
1 Replies

5. AIX

convert a specific date to a unix timestamp

hello, i have an AIX5.3 machine and i am writing a script to display some processes. inside the script i want to get the time that the process starts and convert it to a unix timestamp. is there a command that i can use to do that? i search the web but all i found is long scripts and it does... (4 Replies)
Discussion started by: omonoiatis9
4 Replies

6. UNIX for Dummies Questions & Answers

How to convert R$Timestamp in Sql*Plus within a UNIX Shell Script?

I need to compare a R$Timestamp field sql within a Unix Shell Script. In straight SQL the following code works fine: Table Name: LL_UNIT_TRANSACTION UT Field: R$Timestamp Where TRUNC(UT.R$Timestamp) >= TRUNC(SYSDATE -7) the following returns no data within the Unix Shell Script... (2 Replies)
Discussion started by: Dapconsult
2 Replies

7. 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

8. Shell Programming and Scripting

Convert UNIX timestamp to readable format in the file

Hello I have a file : file1.txt with the below contents : 237176 test1 test2 1442149024 237138 test3 test4 1442121300 237171 test5 test7 1442112823 237145 test9 test10 1442109600 In the above file fourth field represents the timestamp in Unix format. I found a command which converts... (6 Replies)
Discussion started by: rahul2662
6 Replies

9. Shell Programming and Scripting

Convert date in dd mm yyyy format to UNIX timestamp

Hello All, I have a date in DD/MM/YYYY format. I am trying to convert this into unix timestamp. I have tried following: date -d $mydate +%s where mydate = 23/12/2016 00:00:00 I am getting following error: date: extra operand `+%s' Try `date --help' for more information. ... (1 Reply)
Discussion started by: angshuman
1 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
Debian::AptContents(3pm)				User Contributed Perl Documentation				  Debian::AptContents(3pm)

NAME
Debian::AptContents - parse/search through apt-file's Contents files SYNOPSIS
my $c = Debian::AptContents->new( { homedir => '~/.dh-make-perl' } ); my @pkgs = $c->find_file_packages('/usr/bin/foo'); my $dep = $c->find_perl_module_package('Foo::Bar'); TODO
This needs to really work not only for Perl modules. A module specific to Perl modules is needed by dh-make-perl, but it can subclass Debian::AptContents, which needs to become more generic. CONSTRUCTOR
new Constructs new instance of the class. Expects at least "homedir" option. FIELDS
homedir (mandatory) Directory where the object stores its cache. contents_dir Directory where apt-file stores Contents files are stored. Default is /var/cache/apt/apt-file sources A path to a sources.list file or an array ref of paths to sources.list files. If not given uses AptPkg's Config to get the list. dist Used for filtering on the "distributon" part of the repository paths listed in sources.list. Default is empty, meaning no filtering. contents_files Arrayref of Contents file names. Default is to parse the files in "sources" and to look in "contents_dir" for matching files. cache_file Path to the file with cached parsed information from all Contents files. Default is Contents.cache under "homedir". cache Filled by "read_cache". Used by "find_file_packages" and (obviously) "store_cache" verbose Verbosity level. 0 means silent, the bigger the more the jabber. Default is 1. OBJECT METHODS
warning Used internally. Given a verbosity level and a message, prints the message to STDERR if the verbosity level is greater than or equal of the value of "verbose". repo_source_to_contents_paths Given a line with Deban package repository path (typically taken from sources.list), converts it to the corresponding Contents file names. get_contents_files Reads sources.list, gives the repository paths to "repo_source_to_contents_paths" and returns an arrayref of file names of Contents files. read_cache Reads the cached parsed Contents files. If there are Contents files with more recent mtime than that of the cache (or if there is no cache at all), parses all Contents and stores the cache via "store_cache" for later invocation. store_cache Writes the contents of the parsed "cache" to the "cache_file". Storable is used to stream the data. Along woth the information from Contents files, a timestamp is stored. find_file_packages Returns a list of packages where the given file was found. Contents files store the package section together with package name. That is stripped. Returns an empty list of the file is not found in any package. find_perl_module_package( $module, $version ) Given Perl module name (e.g. Foo::Bar), returns a Debian::Dependency object representing the required Debian package and version. If the module is a core one, suitable dependency on perl is returned. If the package is also available in a separate package, an alternative dependency is returned. In case the version of the currently running Perl interpreter is lower than the version in which the wanted module is available in core, the separate package is preferred. Otherwise the perl dependency is the first alternative. AUTHOR
Damyan Ivanov <dmn@debian.org> COPYRIGHT &; LICENSE Copyright (C) 2008, 2009, 2010 Damyan Ivanov <dmn@debian.org> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. perl v5.14.2 2012-01-15 Debian::AptContents(3pm)
All times are GMT -4. The time now is 10:44 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy