Skip to content

Instantly share code, notes, and snippets.

@zhangxc
Created April 27, 2011 15:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zhangxc/944426 to your computer and use it in GitHub Desktop.
Save zhangxc/944426 to your computer and use it in GitHub Desktop.
compare two directories, put the same files into text1, others into text2
#!/bin/sh
# compare two directories, put the same files into text1, others into text2
if test -z "$1" || test -z "$2" || ! test -d "$1" || ! test -d "$2"; then
echo "cmpdir takes two existed directories as parameters!"
exit 1
fi
ls -1 $1 > /tmp/dir1
ls -1 $2 > /tmp/dir2
sort /tmp/dir1 /tmp/dir2 | uniq -d > text1
sort /tmp/dir1 /tmp/dir2 | uniq -u > text2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment