Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

need help with file move script

Status
Not open for further replies.

mixxalot

Technical User
Mar 5, 2003
6
US
Hi all,
I am working on a new unix ksh shell script to do the following:

1. select all files older than 30 days from a directory that contain the string "MPE 0 0 0 -1 2 "

2. move these selected files to another directory.

3. Append a filename extension to each moveed filename that is moved to the new directory without changing the contents of the file.

4. Create another script, this script will remove the files from the directory that are older than 90 days. Run this script from cron.

Once again I would really appreciate your help on this script. I used to be a programmer but since I have not used my coding chops in a while I am rusty on unix programming.

Ben Prusinski
Network Administrator
 
This type of idea might work.
Test in in a sandbox first.
Code:
#!/bin/sh
dirname="/mydirectory"
destdir="/mydestination"
ext="moved"

for all in `find $dirname -type f -ctime 30 | xargs grep -l "MPE 0 0 0 -1 2 "`
do
 mv $all $destdir/$all.$ext || echo "Error: moving $all"
done
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top