ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I have a database of around 4000 files. I use rsync script to transfer from 2 separate updated hdd every month but I need a way to compare a .txt file or .xml file to the updated drive as I cannot use rsync delete because I can not mount all 3 drives at the same time??
Distribution: Ubuntu 11.4,DD-WRT micro plus ssh,lfs-6.6,Fedora 15,Fedora 16
Posts: 3,233
Rep:
just an idea (if you have a few bucks to spare) usb to ide/sata adapters run about $20 USD give or take
just a thought
as for synchronizing, you could do something like
Code:
ls > list.txt
once you have a list then create a text file named say, sync.sh
put in it
Code:
#!/bin/bash
for file in `cat list.txt`
do
copy $1/$file $2/$file
done
then chmod +x sync.sh and invoke it with
[code]
$./sync.sh /source/path /destination/path
assuming the list is one file name per line in the text file that is
not really a option. I have everything all set with a rsync script I just need to remove the old file about 20 of them. but I have the compare Dir1 to a .txt or .xml file some how.
Distribution: Ubuntu 11.4,DD-WRT micro plus ssh,lfs-6.6,Fedora 15,Fedora 16
Posts: 3,233
Rep:
no, diff compares the contents of files line by line, useful for say, applying patches to source code, but doesn't seem to be what you are looking for, it seems at least what you need is something that provides a list of files you want updated, files you want ignored, files you want removed and then something that does a loop and acts accordingly
Okay, this should just about do it. Was getting all tangled up reading 2 different files... Anyhow, this will read a filename from the old_file_list file and grep the new_file_list file for the file name retrieved. If it succeeds in finding the file name in the new file list then grep will return data in my_result, i.e. the my_result file will now be greater than zero size. Now test and if my_result IS zero size the file name returned from the old_file_list doesn't exist in the new file list so delete the file from the old_file_list path.
Code:
#!/bin/bash
cat old_file_list | while read
do
grep "$REPLY" new_file_list >> my_result
if [ ! -s my_result ]
then
rm /old_backup_path/"$REPLY"
fi
rm my_result
done
exit 0
zenity --question --text "Do you want to copy CRU1 to array1 ?"
if [ $? == 0 ] ; then
cp /media/cru/mediaload.txt /media/array1
rsync -a /media/cru /media/array1 | tee >(zenity --progress --title "Tranfer" --text "Coping file from CRU1 to ARRAY. Get a cup of coffee" --percentage=0 )
notify-send 'Please shut down and install CRU2 and run TranferCRU2'
else
notify-send 'Please try again something went wrong'
fi
then i did-------
zenity --question --text "Do you want to Delete old files??"
if [ $? == 0 ] ; then
comm -13 /home/dir1/mediaload.txt /home/dir2/mediaload.txt | xargs -I '{}' rm /home/dir2/'{}'
notify-send 'Please run Verify on Media'
else
notify-send 'Thank You GoodBye!'
fi
with 1tb of info I didn't have enough space to hold to copies and do a simple cp or rm.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.