you should do it with the find command
i will send you the syntax
Main Topics
Browse All TopicsI'm asking for help in writing a script to move some log files. I'm stuck on the date cmd. I want to move any file that ends in .log and whose date is not equal to today. The o/s is Redhat's linux. I've read the man page on the date cmd, and I'm searching for examples on how this is done, but I haven't found it yet. Would somebody help me out with a bit of code? Here's what I've got and this works for me, what I need help with is to figure out how to select the files whose date is not equal to today's date. Thanks
#! /bin/sh
cd /opt/log
mv 2009-05-10*.log /var/httplogs/
cd /var/
tar -cvf 2009-05-10.tar /var/httplogs/
gzip 2009-05-10.tar
USER="username"
PASS="userpassword"
FTPSERVER="servername.doma
ftp -i -n $FTPSERVER << EOF
user $USER $PASS
prompt off
cd /tmp/
put 2009-05-10.tar.gz
bye
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Hey guys thanks a lot. Tintin your solution works great.
Oren - I like your approach because it allows me to leave a few days worth of logs on the server. I want to apply this same type of script to a firewall once I'm done with the web server. And I want to leave 5 days worth of logs on the firewall.
Would you modify this line of code so it moves the files to /opt/log/?
find ./ -ctime -10 -name "*.log" -exec ls {} \;
Tintin - Would you modify your code so it leaves a few days worth of log files on the server?
If I'm over stepping the rules of fair play here let me know and I'll close out this question and open a new one.
Hi,
Apologies for hijacking the thread, but my problem is very similar to this and requires some tweaking.
Finding the files except for 2 for example works OK for me, but moving part needs changing. Because of the nature of the application I am executing this command from, I have effectively 3 concerned locations:
- the home folder where I am going to execute the command from
- the location of the folder I want to find the files in (different to above)
- the location of the folder I want to move the files to (different to above)
So, say I have the "test2.csv" and "test3.csv" /apps/home/source among many other files. I want to move all files except for the 2 above to /apps/home/target.
And my login location (from where I can only execute the find and move command) is /apps/dsbin/.
Does anybody have any idea how I can achieve this?
Thanks,
Benak
Business Accounts
Answer for Membership
by: WestezPosted on 2009-05-13 at 21:15:01ID: 24381684
I'm in the Central Time zone. A lot of the code I've been checking out mentions the timezone.