Need to find created date of file in UNIX


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Need to find created date of file in UNIX
# 1  
Old 06-30-2006
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  
Old 06-30-2006
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  
Old 07-04-2006
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  
Old 07-04-2006
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 08:53 PM..
# 5  
Old 07-05-2006
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  
Old 07-05-2006
Code:
find /path/to/directory  -mtime +180 -exec rm -f {} \;

# 7  
Old 07-05-2006
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
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Find the count of files by last created date based on the given date range

My unix version is IBM AIX Version 6.1 I tried google my requirement and found the below answer, find . -newermt “2012-06-15 08:13" ! -newermt “2012-06-15 18:20" But newer command is not working in AIX version 6.1 unix I have given my requirement below: Input: atr files: ... (1 Reply)
Discussion started by: yuvaa27
1 Replies

2. Shell Programming and Scripting

Find the file created on current date

Hi All, I'm trying to find a file which is created on current day.... I searched in unix.com and i found, below command. find /land/ -mtime -1 -type f -print | grep "FF_Member_STG.dat" The command checks if the file with name "FF_Member_STG.dat" is created today then exit else proceed. ... (3 Replies)
Discussion started by: ace_friends22
3 Replies

3. HP-UX

How to find a file created in UNIX every monday.???

Hi All Any one please suggest me... I have one directory every monday one file will be created in that directory. so if the file is created on monday or not i need check first. How can write a script??? if the file is not created i want to quit from script. Thanks K.Srinivas (5 Replies)
Discussion started by: k_s_rao7
5 Replies

4. UNIX for Dummies Questions & Answers

Can we change the file created date?

Hi, I am creating a file in unix today. Is it possible to make the file created as 2 days older (or some past date)? P.S: i dont want to change the system date to older one and try.:rolleyes: Thanks, Pandeeswaran (6 Replies)
Discussion started by: pandeesh
6 Replies

5. AIX

How to find the date on which a particular directory is created?

how to find the date on which a particular directory is created? Thanks. (4 Replies)
Discussion started by: samsungsamsung
4 Replies

6. Shell Programming and Scripting

Find first created file date in YYYYMMDD format

Hi All, We are copying all the files into ARCHIVE directory after we process them. We are doing this process from last 2 years, now we have a lot of files in ARCHIVE directory. Now I need to find when the first file is copied into this directory? If I Issue, ls -l /ARCHIVE/*.* | tail -1... (3 Replies)
Discussion started by: Raamc
3 Replies

7. Shell Programming and Scripting

Find unix file created how many days ago?

i want to find unix file created how many days ago? (4 Replies)
Discussion started by: utoptas
4 Replies

8. Shell Programming and Scripting

Rename File Based on Created Date

I am trying to rename files based on the created/born date of the file. I Have a total of 4000 files that i am trying to do this with and would like it to be log_yyyymmddhh.gz right now the files are maillog.???.gz. Can anyone point me in the right direction of how to get this done via scipt? ... (4 Replies)
Discussion started by: Paulb
4 Replies

9. UNIX for Dummies Questions & Answers

Finding the date a file was created

how do i find the date a file was created? (3 Replies)
Discussion started by: trob
3 Replies

10. UNIX for Dummies Questions & Answers

how to find folder size with created date

hi, please give me adivse .how to find the folder size with created created date . eg: i have directore and in that sub directoties and so on.. /home/mud/abc/dcb/ for this i want output like this path size date -------------------------------------------... (3 Replies)
Discussion started by: muddasani
3 Replies
Login or Register to Ask a Question