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
Open .zip file created in UNIX sam99 UNIX for Dummies Questions & Answers 5 07-04-2008 07:58 AM
When a file is created where does unix store the info? goodmis UNIX for Advanced & Expert Users 5 02-04-2007 01:16 AM
File management based on date created Geehog_Rare UNIX for Dummies Questions & Answers 1 01-30-2006 04:38 AM
Determine date and time the file was created through shell scripts BharatSurana Shell Programming and Scripting 1 01-11-2006 01:06 PM
I want to get the file which created the error when the find command was run guhas Shell Programming and Scripting 1 10-21-2005 03:06 PM

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 Rating: Thread Rating: 1 votes, 5.00 average. Display Modes
  #1 (permalink)  
Old 06-30-2006
amirthraj_12 amirthraj_12 is offline
Registered User
  
 

Join Date: Jun 2006
Posts: 10
Need to find created date of file in UNIX

[FONT=Arial][SIZE=7][COLOR=Blue]

I need to write a script which has to list all the files which are created before six months from now.

kindly help on this ...
  #2 (permalink)  
Old 06-30-2006
jim mcnamara jim mcnamara is offline Forum Staff  
...@...
  
 

Join Date: Feb 2004
Location: NM
Posts: 5,717
UNIX does not have a created date. What you want is the last time the file was modified - that date. Using 180 days for six months (you can adjust the number)

Code:
find /path/to/directory  -mtime +180
lists all of the files older than six months.
Code:
find /path/to/directory  -mtime +180 -exec ls -l {} \;
gives a long directory listing... so you can verify dates.
  #3 (permalink)  
Old 07-04-2006
vijay.amirthraj vijay.amirthraj is offline
Registered User
  
 

Join Date: Jul 2006
Posts: 2
How to delete the files

How can I delete these files once i get from this find command.

kindly assist please.. this is an urgent issue
  #4 (permalink)  
Old 07-04-2006
vgersh99's Avatar
vgersh99 vgersh99 is online now Forum Staff  
Moderator
  
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 5,119
Quote:
Originally Posted by vijay.amirthraj
How can I delete these files once i get from this find command.

kindly assist please.. this is an urgent issue
for any 'urgent' issue try to understand a given hint, browsE the relative 'man' pages' for further help and come back with specific questions.

Last edited by vgersh99; 07-04-2006 at 07:53 PM..
  #5 (permalink)  
Old 07-05-2006
Dhruva's Avatar
Dhruva Dhruva is offline
Registered User
  
 

Join Date: Mar 2006
Location: India
Posts: 255
You can remove file in a similar way mcnamara suggested.

find /path/to/directory -mtime +180 -exec rm {} \;

remember here it is necessary to give semicolon and has to be preceded by \ to take away its special meaning.here {} indicate that searched files would become arguments for rm.
  #6 (permalink)  
Old 07-05-2006
jim mcnamara jim mcnamara is offline Forum Staff  
...@...
  
 

Join Date: Feb 2004
Location: NM
Posts: 5,717
Code:
find /path/to/directory  -mtime +180 -exec rm -f {} \;
  #7 (permalink)  
Old 07-05-2006
ShawnMilo ShawnMilo is offline
Registered User
  
 

Join Date: Jun 2006
Posts: 252
Quote:
Originally Posted by amirthraj_12
[FONT=Arial][SIZE=7][COLOR=Blue]

I need to write a script which has to list all the files which are created before six months from now.

kindly help on this ...
Use ctime instead of atime. I'm also assuming that you meant "created more than six months ago," because everything was created before six months from now."

find . -ctime +180
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 08:33 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