[SlugBug] shell script help

Beneath ishikodzume at beneath.plus.com
Wed Aug 6 23:35:44 BST 2003


Hi,

> i want to write a bash script to compare each file in directory2 to
> each file in directory1 and, if the files are the same, to delete the
> file in directory2.  if a file in directory2 does not match any file
> in directory1 then no action is taken.

for FILE in $(ls directory1/*); do
  for FILE2 in $(ls directory2/*); do
    if [ $(cmp $FILE $FILE2) -eq 0 ]; then
      rm $FILE2
    fi
  done
done

Should work.

 - Daniel


-=-=-=-
PGP: http://spacecake.hypermart.net/pgp/ishikodzume.pubkey.asc
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://www.email-lists.org/pipermail/slugbug/attachments/20030806/9b9112d2/attachment.bin


More information about the SlugBug mailing list