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
Help needed - ksh shell scripting subbu Shell Programming and Scripting 5 02-15-2008 12:53 PM
SHell Scripting Help Needed cskumar Shell Programming and Scripting 2 07-17-2006 01:55 AM
Help needed - shell scripting garric Shell Programming and Scripting 8 05-23-2006 06:08 AM
scripting....guru's help needed sekar sundaram Shell Programming and Scripting 2 11-13-2005 03:57 AM

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 Rate Thread Display Modes
  #1 (permalink)  
Old 09-02-2007
vats vats is offline
Registered User
  
 

Join Date: Aug 2007
Posts: 10
little scripting help needed!!

guys i need bit of help!!

i am writing a script which finds files that have not been accessed for a no of days and delete those files...the no of days value is inputted at the command line....

i am using the following :
find $1 -atime +7 -exec rm -i

in the second step i want to copy all of those files that the above lines find to a list and archive them using GNU tar...once i archive these files i can go on and delete them.....Also the archive name should include the date so that a existing archive not be overwritten...

any help guys????
  #2 (permalink)  
Old 09-02-2007
Klashxx's Avatar
Klashxx Klashxx is offline Forum Advisor  
HP-UX/Linux/Oracle
  
 

Join Date: Feb 2006
Location: Almerķa, Spain
Posts: 393
Hi, not tested , but you can try:

Code:
 find $1 -atime +7|xargs -i ksh -c 'echo {} >>/tmp/list;mv {}  /tmp'

dt=$(date +%Y%m%d)

tar cvzf file${dt} /tmp/*
  #3 (permalink)  
Old 09-02-2007
digen digen is offline
Registered User
  
 

Join Date: Feb 2007
Posts: 4
Shouldn't it be,

Quote:
find . -atime $1
for the find command to find files which haven't been accessed over 24 hours*n ? Since the number of days would be input using the positional parameter ?

Quote:
-atime n
File was last accessed n*24 hours ago. When find figures out how many 24-hour periods ago the file was last accessed, any fractional part is ignored, so to match -atime +1, a file has to have been accessed atleast two days ago.
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 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