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
Compare two dates using Shell Programming dave_nithis Shell Programming and Scripting 4 01-04-2008 05:18 AM
compare dates... i_priyank Shell Programming and Scripting 3 09-21-2007 12:50 AM
compare dates ragha81 Shell Programming and Scripting 2 11-01-2006 06:17 PM
How to compare dates in C/C++ naan High Level Programming 1 08-28-2006 10:03 AM
How to compare two dates bankpro High Level Programming 5 01-24-2006 04:07 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 02-23-2007
vaji vaji is offline
Registered User
  
 

Join Date: Feb 2007
Posts: 5
Thumbs up How to compare the dates in shell script

Hi

How to compare created or modified date of two files

help needed

thanks
Vajiramani
  #2 (permalink)  
Old 02-23-2007
ahmedwaseem2000 ahmedwaseem2000 is offline
Registered User
  
 

Join Date: Aug 2005
Location: Bangalore
Posts: 219
Quote:
Originally Posted by vaji
Hi

How to compare created or modified date of two files

help needed

thanks
Vajiramani
what exactly are you trying to achieve here
  #3 (permalink)  
Old 02-24-2007
srikanthus2002's Avatar
srikanthus2002 srikanthus2002 is offline
Registered User
  
 

Join Date: Sep 2006
Location: Can u guess...!
Posts: 160
you can check this way

-rw-rw-r-- 1 kanth kanth 0 Feb 24 11:33 created_file
-rw-rw-r-- 1 kanth kanth 0 Feb 24 11:33 modified_file


suppose you have two file as above...


take 6,7 and 8th column and compare it by using "if" conditions

create=`ls -lrt created_file | awk '{print $6$7$8}'`
modify=`ls -lrt modified_file |awk '{print $6$7$8}'`
  #4 (permalink)  
Old 02-24-2007
udaykishore udaykishore is offline
Registered User
  
 

Join Date: May 2006
Location: London
Posts: 19
u can use find (-mtime/-atime/-ctime) feature

U can use find command .
it has various options
-mtime 3 --to find files modified exactly 3days ago
-mtime +3 --to find files modified more than 3days
-mtime -3 --to find files modified within 3days

similarly
u have
-atime,-ctime and -newer etc
  #5 (permalink)  
Old 02-26-2007
vaji vaji is offline
Registered User
  
 

Join Date: Feb 2007
Posts: 5
How to get command line parameter to be used in script

Thank u its help full.

Actually what i want to trying to do is getting some parameters as command line arguments while running a shell script and use it. Then with this i need to delete files from a directory if its exceeding the count 7.

The above command will delete wat ever the specified date interval. Its also in away good but i need exactly 7 files in the directory even if i don't generate one file for a day.

Now i need how to get command line parameters to be used int he script

Thanks again

Last edited by vaji; 02-26-2007 at 06:55 AM..
  #6 (permalink)  
Old 02-26-2007
anbu23 anbu23 is offline Forum Advisor  
Registered User
  
 

Join Date: Mar 2006
Location: Bangalore,India
Posts: 1,398
Code:
scpt
###########
echo $1  # Gives the first argument
echo $2  # Gives the second argument
echo $3  # Gives the third argument
###########
Call the scpt with three arguments
Code:
script arg1 arg2 arg3
If you pass more than 9 arguments, then use brace
Code:
echo ${10}
echo ${11}
If your string argument contain spaces then use double quotes
Code:
scpt "hi buddy" arg2 arg3
  #7 (permalink)  
Old 02-26-2007
vaji vaji is offline
Registered User
  
 

Join Date: Feb 2007
Posts: 5
Hi dears

its helpful

Thank you
Sponsored Links
Closed Thread

Bookmarks

Tags
mtime

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 05:00 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