This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
Usage: ./cmpdir d1 d2
`sort' just sort the lines alphabetically. the key is uniq

没有评论:
发表评论