Welcome, Guest
Username Password: Remember me

identical file validation using shell script?
(1 viewing) (1) Guest
Shell Script
  • Page:
  • 1

TOPIC: identical file validation using shell script?

identical file validation using shell script? 1 year, 5 months ago #443

  • scmuser
  • OFFLINE
  • Gold Boarder
  • scm master
  • Posts: 237
  • Points: 3429
  • Karma: 0
  • Honor Medal 2009
Device a script that accepts two directory names, bar1 and bar2, and deletes those files in bar2 which are identical to their namesakes in bar1.

Re: identical file validation using shell script? 1 year, 5 months ago #446

  • rajeshkumar
  • OFFLINE
  • Moderator
  • I love software configuration management
  • Posts: 370
  • Points: 44590
  • Karma: 4
  • Honor Medal 2009
Solution:

#!/bin/bash
cd $1
for file in * ; do
if [ -f ../$2/$file ] ; then
cmp $file ../$2/$file >/dev/null 2>/dev/null && rm ../$2/$file
fi
done
Regards,
Rajesh Kumar
Build and Release Engineer
My Blog: community.scmgalaxy.com/pg/profile/rajeshkumar
  • Page:
  • 1
Time to create page: 0.71 seconds

     
    
Home Forum