在某一个目录中寻找与指定的文件内容相同的文件
冷胜魁(Seaquester)
lengshengkui@gmail.com
2009-5-15
#!/bin/bash
# Compare a file with all files under a specified directory.
if [ -z "$1" ] ; then
echo "Usage: `basename $0` "
exit 1
fi
if [ -z "$2" ] ; then
DIR=`pwd`
else
DIR="$2"
fi
SRC="$1"
for file in $DIR/* ; do
cmp $SRC $file 1>& /dev/null
if [ $? -eq 0 ] ; then
echo "`basename $file`"
fi
done
阅读(1620) | 评论(2) | 转发(0) |