How long ago since time - Using perl


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How long ago since time - Using perl
# 1  
Old 05-18-2012
How long ago since time - Using perl

Code:
echo "1337124526" | perl -pe 's/(\d+)/easttime($1)/e'

the above gives a date and time.

how can i subtract the date and time given by this command, from the current present date?

can this be a one liner or as close to a one-liner as possible?
# 2  
Old 05-19-2012
You get now with:
Code:
date +%s

so all you really need is:
Code:
echo "($(date +%s) - 1337124526)/(60*60)" | bc -l

Result in hours.
This User Gave Thanks to mirni For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

First script in a long time

I was wondering if I could get some feedback on my script to grab time from our MDM... I blocked out all of the important stuff. I really appreciate any guidance, since I am long out of practice. #!/bin/bash serial=$1 # get last seen value of ipad lastseen=$(curl -s -X "GET"... (11 Replies)
Discussion started by: andysensible
11 Replies

2. UNIX for Dummies Questions & Answers

ls is taking long time to list

Hi, All the data are kept on Netapp using NFS. some directories are so fast when doing ls but few of them are slow. After doing few times, it becomes fast. Then again after few minutes, it becomes slow again. Can you advise what's going on? This one directory I am very interested is giving... (3 Replies)
Discussion started by: samnyc
3 Replies

3. Shell Programming and Scripting

sort takes a long time

Dear experts I have a 200MG text file in this format: text \tab number I try to sort using options -fd and it takes very long! is that normal or I can speed it up in some ways? I dont want to split the file since this one is already splitted. I use this command: sort -fd file >... (12 Replies)
Discussion started by: voolek
12 Replies

4. UNIX for Advanced & Expert Users

getting time mins ago

Hi I trying to get 5 mins ago time using below command echo `date +%R -d "1 min ago"` but this is giving only current time. Please help (6 Replies)
Discussion started by: cka
6 Replies

5. UNIX for Dummies Questions & Answers

Job is taking long time

Hi , We have 20 jobs are scheduled. In that one of our job is taking long time ,it's not completing. If we are not terminating it's running infinity time actually the job completion time is 5 minutes. The job is deleting some records from the table and two insert statements and one select... (7 Replies)
Discussion started by: ajaykumarkona
7 Replies

6. Shell Programming and Scripting

how to calculate the time 10 mins ago?? unix

Hi guys, Im trying to subtract time in ksh script. i.e. basically im querying a database and i want to get the time 10mins before hand..(from) in ksh CurrMin=$(date "+%M") from=`expr $CurrMin - 10` to=$CurrMin however if i run this i say at 2 or 3 mins past the hour, i.e.... (7 Replies)
Discussion started by: k00061804
7 Replies

7. Shell Programming and Scripting

help - exec time too long

Dear everyone... thanks to this forum I am able to do everyday more and more complex scripts...but now I come up with problem with optimisation.. problem 1 - optimise: here is my code: while read number do nawk -F "|" -v... (8 Replies)
Discussion started by: abdulaziz
8 Replies

8. AIX

How long does AIX resync the time with another server

Hi, I have NTP configured: vi /etc/ntp.conf broadcastclient server 128.127.1.3 driftfile /etc/ntp.drift tracefile /etc/ntp.trace # xntpdc xntpdc> sysinfo system peer: 128.127.1.3 system peer mode: client leap indicator: 00 stratum: 12 precision: ... (0 Replies)
Discussion started by: victorcheung
0 Replies

9. Programming

Debug env for long time use

Hi, I'm pritty new to C, but a recent bug in a program i've been using has forced me to debug it. But I am unable to find a debugger that can act as a layer between the OS and the program to see whats going on.. The problem is that this piece of software makes a connection through localhost... (2 Replies)
Discussion started by: nephilimbe
2 Replies

10. AIX

rcp gets hung for long time

Every evening I run a script in AIX production box, which executes below command: rcp prod_bkup.tar prodapp@IP:/data/appl/prod This will rcp a backup of around 11 GB from production to another machine (runs every evening so overwrites previous one). Just to keep the backup safe. Since 2-3 days,... (0 Replies)
Discussion started by: panchpan
0 Replies
Login or Register to Ask a Question