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
Create Year directory, date subdirectory and archive the file madhunk UNIX for Dummies Questions & Answers 2 12-13-2007 11:25 AM
parsing a system log file via the 'date' command cjones Shell Programming and Scripting 5 05-10-2007 12:26 PM
How to create a new file system tintedwindow UNIX for Dummies Questions & Answers 3 04-17-2007 09:27 PM
create a new file system rongrout SCO 2 09-22-2004 09:13 PM
file date vs. system date ober5861 UNIX for Dummies Questions & Answers 8 09-11-2001 02:36 PM

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 10-17-2006
hamsa hamsa is offline
Registered User
  
 

Join Date: Oct 2006
Posts: 7
need to create a file with its name having system date

Hi,

Iam new to unix . I need to write a scritp which can create a file having sysdate as a part of it.and i also need to delete file which is created five days before in a directory.pls Help me out

thanks in advance
  #2 (permalink)  
Old 10-17-2006
Yogesh Sawant's Avatar
Yogesh Sawant Yogesh Sawant is offline Forum Staff  
Part Time Moderator and Full Time Dad
  
 

Join Date: Sep 2006
Location: Rossem, Tazenda
Posts: 1,086
this will help you to create a filename that contains system date:

Code:
touch  my_file`date +%d-%m-%Y`contains_date
  #3 (permalink)  
Old 10-17-2006
hamsa hamsa is offline
Registered User
  
 

Join Date: Oct 2006
Posts: 7
Thanks for the info.but how can i delete files in a directory that are created 5 days back.....
  #4 (permalink)  
Old 10-17-2006
justsam
Guest
  
 

Posts: n/a
Bits: 0 [Banking]
/usr/bin/find "Directory Path" -type f -mtime +5 -exec /bin/rm -f {};

Ex: /usr/bin/find /home/justsam -type f -mtime +5 -exec /bin/rm -f {};

Note: The above deletes only the files (mentioned by the type switch) in the directory /home/justsam wich are older than 5 days (mentioned by -mtime). If you want to delete files older than 3 days, make it -mtime +3

Last edited by justsam; 10-17-2006 at 07:32 AM.. Reason: Changing the path
  #5 (permalink)  
Old 10-17-2006
hamsa hamsa is offline
Registered User
  
 

Join Date: Oct 2006
Posts: 7
Thanks i want to delete a file based on the created time not modified.Will the above command works for this.

For ex if i modify a file which was created five days earlier will it also gets deleted
  #6 (permalink)  
Old 10-17-2006
Yogesh Sawant's Avatar
Yogesh Sawant Yogesh Sawant is offline Forum Staff  
Part Time Moderator and Full Time Dad
  
 

Join Date: Sep 2006
Location: Rossem, Tazenda
Posts: 1,086
the mtime option of find command lets you select files based on their time of modification.

the atime option of find command lets you select files based on their time of access.

as far as i know, find command does not give you any option to select files based on time of creation.

do man find to know more.
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 09:24 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