Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
hey,
i am trying to write a bash script to backup recent files from a directory.
it works well, except that it does not copy files whose names have brackets.
(i.e. banner[1].jpg)
any advice on how i might be able to do this, or on code that would find and rename such files before i run my copy script?
thanks!
-matt
my script
____
#!/bin/sh# this script will backup all files from the last month to a secondary location
date=$(date "+%m-%d-%y")
# mkdir backup_$date
cd /Volumes/192.168.1.15/apps/GoldMine/Mailbox/Attach/find . -mtime 1 | \
while read filedo
#avoiding pesky trivial output
if [ "$file" = "." ]
then
else
echo "$file"
cp "$file" /Volumes/192.168.1.108/ScriptTest/backup_$date/"$file"
fi
done

targetdir="/Volumes/192.168.1.108/ScriptTest/backup_${date}/"
for file in `find . -type f -mtime -1` ; do
cp $file $targetdir
doneSee if you have a "rename command". Otherwise you could rename with sed.
file=`echo $file | sed -e 's/\[//' -e 's/\]//'`

![]() |
ksh script if then if?
|
Setting Unix env
|

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |