Compare files

Asked by peter

Hello

I've a question and I would be glad if you can help. Thanks.

I've created a shell script with the following commands:

#!/bin/bash
cd /root/Own_Data
find . | sort > /tmp/Hdisc.txt
cd /media/disk/Own_Data
find . | sort > /tmp/USB.txt
cd /tmp
diff Hdisc.txt USB.txt
echo
read

This script works. If i create a new file on the harddisc or if I delete a file on the harddisc I'll get the notification.

But if I update a file on the harddisc I don't get a notification.

What do I have to do to get a notification if I update a file? Thanks.
Peter

Question information

Language:
English Edit question
Status:
Solved
For:
Ubuntu kdiff3 Edit question
Assignee:
No assignee Edit question
Solved by:
peter
Solved:
Last query:
Last reply:
Revision history for this message
marcobra (Marco Braida) (marcobra) said :
#1

You need to test the the date modified of every files if they are only modified... find give you only the filename as result... try the "ls" find parameter...

try to read the diffrence from:

find . -ls | sort > /tmp/Hdisc.txt

and

find . -ls | sort > /tmp/USB.txt

Hope this works

Revision history for this message
peter (peter-neuweiler) said :
#2

Hi marcobra

Thanks for your hint. But: it doesn't work.

I didn't modify a file. I modified the shell script and executed it. I got the following output:

/linux_desktop
> 83 32 drwx------ 2 root root 32768 Jan 1 01:40 ./Sys_Admin/linux_desktop/Background
> 86 32 -rwx------ 1 root root 24074 Jul 3 2008 ./Sys_Admin/linux_desktop/Background/pengui.jpg
> 87 576 -rwx------ 1 root root 561688 Apr 9 2008 ./Sys_Admin/linux_desktop/Background/warty-final-ubuntu.png
> 88 32 drwx------ 5 root root 32768 Jan 6 16:23 ./Sys_Admin/linux_desktop/Icons
> 92 128 drwx------ 2 root root 131072 Nov 24 17:22 ./Sys_Admin/linux_desktop/Icons/ubuntu

I guess ls is the wrong command. Because ls lists the directory contents. Do you have another idea? Thanks a lot.
Peter

Revision history for this message
marcobra (Marco Braida) (marcobra) said :
#3

Please tell better what are you trying to do... you are sure you need a script.. what you need to keep in sync...?
May be there is already a ready to install package that do what you a trying to do...?

Thank you

Revision history for this message
Sam_ (and-sam) said :
#4

Options:
man diff
GUI:
Gnome:meld, Gnome Commander
KDE:kompare or kdiff3
other:
mgdiff, tkdiff, xxdiff

Revision history for this message
peter (peter-neuweiler) said :
#5

Hi marcobra

I've a harddisc and I've an USB-stick. But the USB-stick was very, very cheap. So I didn't trust the stick. I would get a script to compare the disc and the stick.

The script mentioned above works if I delete or create a file on the harddisc. But the script doesn't work, if I modify a file on the harddisc. That's it.

Thanks.
Peter

Revision history for this message
peter (peter-neuweiler) said :
#6

Hi marcobra

I found the solution: kdiff3. Thanks a lot.
Peter

Revision history for this message
peter (peter-neuweiler) said :
#7

Hi Sam

Thanks for the hint regarding kdiff3. It helped. Thanks.
Peter