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 > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Compare date from db2 table to yesterday's Unix system date sasaliasim Shell Programming and Scripting 9 12-01-2008 11:37 PM
Perl: Extracting date from file name and comparing with current date MKNENI Shell Programming and Scripting 4 03-26-2008 04:01 PM
date issue-find prevoius date in a patricular format bsandeep_80 UNIX for Advanced & Expert Users 3 11-15-2007 08:42 PM
Changing Creation Date to a Prespecified Date of a File In Unix monkfan UNIX for Dummies Questions & Answers 4 11-28-2006 07:15 AM
a simple way of converting a date in seconds to normal date travian HP-UX 2 11-23-2006 12:25 PM

 
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 08-02-2005
radhika radhika is offline
Registered User
  
 

Join Date: Apr 2005
Posts: 51
date is not getting the filedate value.

I have the following script. I am trying to get the date time when an empty file was created. In my situation if an empty file is created it won't be touched again. At the end of the script I state the problem- the
#!/bin/ksh
#Source the file
. $HOME/.profile
typeset -L100 fname
typeset -L14 fdate
typeset -R12 reccnt
typeset -R12 charcntfinal
typeset -R12 cnt1
typeset -R12 cnt2
typeset -R12 sum1

fname=$1

#Get the actual date when the file was created, clip it from the actual data file.
fdate=`cut -c1-14 $fname`
echo fdate1: $fdate

#Get file size.
filesize=`ls -lrt $fname | awk '{ print $5 }'`
echo filesize is: $filesize

#Checks to see if variable is empty or if file size is 0.
if [[ -z $fdate ]] || [ $filesize = "0" ]
then
echo fdate is empty or fdate file size is 0.
#Get the date and time when the empty file was created.
#get the date time value from the ls -al output, where the delimiter is the file size (which is 0)
filedate=`ls -al $fname | cut -f2-4 -d'0' | cut -f1-4 -d' ' `
echo fdate when file was created is: $filedate
date=$filedate
fdate=`date +%Y%m%d%H%M%S` (#PROBLEM? here date is not getting $filedate value. It still picks up the current date value. Don't know why?)
echo date time when file was created is: $fdate
fi

"perf_totals.sh" 73 lines, 2429 characters
ussun0s/scripts>

#Running the script..............................
ussun0s/scripts> perf_totals.sh gsk_vac.txt gsk_vac_control.txt
fdate1:
filesize is: 0
fdate is empty or fdate has spaces
fdate when file was created is: Jul 21 00:54
date time when file was created is: 20050802142511 (this is the problem. I am still getting the current date here, rather than the fdate when file was created.)

Any help is greatly appreciated.
Regards,
Radhika.
 

Bookmarks

Tags
linux

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 02:25 AM.


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