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
help in script modification a.suryakumar Shell Programming and Scripting 4 03-13-2008 02:12 AM
crontab entry modification using shell script munishdh Shell Programming and Scripting 4 07-01-2007 06:47 AM
Specify a previous date as start date in shell script ritzwan0 Shell Programming and Scripting 2 09-25-2006 06:58 PM
Search by modification date slink UNIX for Dummies Questions & Answers 5 05-25-2006 07:07 AM
command for modification date of a file scampsd UNIX for Dummies Questions & Answers 5 12-28-2005 08:14 AM

Closed Thread
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
  #1 (permalink)  
Old 07-05-2006
onlyc onlyc is offline
Registered User
  
 

Join Date: Jul 2006
Posts: 7
Question Shell script: last modification date for a file

Hi i have a ques in Shell scripting:

ques: accept a filename as a command line argument. Validate the input and display the last modification date for that file.

Help pls.
  #2 (permalink)  
Old 07-05-2006
vino's Avatar
vino vino is offline Forum Staff  
Supporter (in vino veritas)
  
 

Join Date: Feb 2005
Location: Bangalore, India
Posts: 2,798
What have you done so far ?

Looks like homework..
  #3 (permalink)  
Old 07-05-2006
onlyc onlyc is offline
Registered User
  
 

Join Date: Jul 2006
Posts: 7
last modification date

What i have done is: accepted user input and done validation to check if the file is a valid one.
But i cant retrieve the last modification date...


I have tried using :
ls -l , put it into a file and then used cut command to display the date... but the cut command is not working!
  #4 (permalink)  
Old 07-05-2006
Dhruva's Avatar
Dhruva Dhruva is offline
Registered User
  
 

Join Date: Mar 2006
Location: India
Posts: 255
you can try this..

ls -l filename|awk '{print $6 $7 $8}'

or if you want to catch in some variables for month,day,hour
use this in your script.

modf_time=`ls -l filename`

time_month=`echo $modf_time | awk '{print $6}'`
time_day=`echo $modf_time | awk '{print $7}'`
time_hrmin=`echo $modf_time | awk '{print $8}'`
time_hr=`echo $time_hrmin | cut -d ':' -f1`
time_min=`echo $time_hrmin | cut -d ':' -f2`

echo $time_month $time_day $time_hr $time_min
  #5 (permalink)  
Old 07-06-2006
onlyc onlyc is offline
Registered User
  
 

Join Date: Jul 2006
Posts: 7
Question Thanx!

Thank you...
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 12:17 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