The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Use awk to create new folder in current directory ccox85 Shell Programming and Scripting 6 01-28-2008 03:59 AM
Generating files with time interval of fifteen minutes aajan Shell Programming and Scripting 0 09-25-2007 01:54 AM
Adding # minutes to current time... gptavares UNIX for Advanced & Expert Users 7 06-25-2007 03:10 PM
how to display time in minutes n seconds... santy Shell Programming and Scripting 1 08-23-2006 10:18 AM
time stamp of file create nhatch UNIX for Dummies Questions & Answers 7 06-14-2004 10:32 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 10-05-2005
DaveyTN DaveyTN is offline
Registered User
  
 

Join Date: Oct 2005
Posts: 2
How can I create a file with current time - 60 minutes

I'm using k-shell in unix and I want to create a file with the current system time - 60 minutes. I know I can use touch to create the file, but I'm having trouble specifying how tell it to use the current time less 60 minutes. Any ideas???
  #2 (permalink)  
Old 10-05-2005
blowtorch's Avatar
blowtorch blowtorch is offline Forum Advisor  
Supporter
  
 

Join Date: Dec 2004
Location: Singapore
Posts: 2,350
Use this:
Code:
perl -w -e '@mytime=localtime (time - $ARGV[0]); printf "%d%.2d%.2d%.2d%.2d", $mytime[5]+1900,$mytime[4]+1,$mytime[3],$mytime[2],$mytime[1];' 3600
The output of the above command can be used by touch to create a file.

This is part of a script that can find files created in the last few minutes or few hours. That script can be found here.
  #3 (permalink)  
Old 10-05-2005
DaveyTN DaveyTN is offline
Registered User
  
 

Join Date: Oct 2005
Posts: 2
Thanks. Do you know how I can do this in k-shell instead of pearl?
  #4 (permalink)  
Old 10-05-2005
blowtorch's Avatar
blowtorch blowtorch is offline Forum Advisor  
Supporter
  
 

Join Date: Dec 2004
Location: Singapore
Posts: 2,350
You only have the date command in ksh and would have to write a script to fiddle with the output of that. The perl version is much easier. Unless you do not have perl installed on your system, I suggest you go with perl.
  #5 (permalink)  
Old 10-05-2005
Perderabo's Avatar
Perderabo Perderabo is offline Forum Staff  
Unix Daemon
  
 

Join Date: Aug 2001
Location: Ashburn, Virginia
Posts: 9,111
This needs my datecalc script which is also on this site...
Code:
#! /usr/bin/ksh

alias datecalc=./datecalc
set -A t $(date "+%Y %m %e %H %M")
echo "datecalc -a ${t[0]} ${t[1]} ${t[2]} - 1"
if ((${t[3]})) ; then
        ((t[3]=t[3]-1))
else
        set +A t $(datecalc -a ${t[0]} ${t[1]} ${t[2]} - 1) 23 ${t[4]}
fi
year=${t[0]}
typeset -Z2 t

timestamp=${year}${t[1]}${t[2]}${t[3]}${t[4]}

touch -t $timestamp xfile
ls -l xfile

exit 0
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 01:55 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0