![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| 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 |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
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 |
| Display Modes | Rate This Thread |
|
|