Operating System - HP-UX
1833457 Members
2847 Online
110052 Solutions
New Discussion

Re: need help with shell script

 
vz7r1x
Regular Advisor

need help with shell script

I want my script to move files that are older than 5 days to a archive directory, but I am unable do it. Can you give ideas? Below is what I tried:
#!/bin/sh
ls -altr /var/.audit >> /tmp/AuditMove.txt
find /var/.audit/*.* -mtime +5 -exec mv {} \;

exit
7 REPLIES 7
Robert-Jan Goossens_1
Honored Contributor

Re: need help with shell script

find /var/.audit/ -mtime +5 -exec mv {} \;

regards,
Robert-Jan
Peter Godron
Honored Contributor

Re: need help with shell script

Hi,
does your mv fail ?
You have not defined where you want to move the files to !

You need something like:
# find /var/.audit/*.* -mtime +5 -exec mv {} /tmp/ \;

Please also read:
http://forums1.itrc.hp.com/service/forums/helptips.do?#33 on how to reward any useful answers given to your questions.
James R. Ferguson
Acclaimed Contributor

Re: need help with shell script

Hi:

# find /path -xdev -type f -mtime +5 | xargs -i mv {} /newpath

Regards!

...JRF...
vz7r1x
Regular Advisor

Re: need help with shell script

Thanks you all. solved my problem. I was not placing {} properly. Thanks Peter and James.
vz7r1x
Regular Advisor

Re: need help with shell script

Thanks
Peter Godron
Honored Contributor

Re: need help with shell script

Hi,
could you please read:
http://forums1.itrc.hp.com/service/forums/helptips.do?#41
and then
http://forums1.itrc.hp.com/service/forums/helptips.do?#33

How much time/frustration did the answers save you ?
vz7r1x
Regular Advisor

Re: need help with shell script

Peter
I really love this forum and I told my HP reps so many times about greatness of this forum and its members. This reply saved me enormous time, hours of my time.

Now I am trying to learn enough to contribute to this forum too, its like paying back to the forum in return for what I gain from it.
Thanks