答问题抢高分!!! 不够再加!!!
UNIX 操作的问题
1。 用diff等命令找出两个目录中名字相同而内容不同的文件的名字
2。 把本目录下文件名以a开始的文件改名为以b开始的方法是?
问题点数:100、回复次数:2Top
1 楼waterstream((*星*雨*))回复于 2002-06-21 17:44:57 得分 0
go away!!!!!!!!!!!!!!!!!!!!1Top
2 楼qxp()回复于 2002-06-21 18:54:55 得分 100
1.
#!/bin/sh
SRC_DIR=$1
DST_DIR=$2
for file in `ls $SRC_DIR`
do
if [ -f $file ]
then
diff -q $SRC_DIR/$file $DST_DIR 2>&1 >/dev/null
if [ $? = 0 ]
then
echo $file in $SRC_DIR and $DST_DIR is same
else
echo $file in $SRC_DIR and $DST_DIR is different
fi
fi
done
2.
#!/bin/sh
for file in `ls`
do
if [ -f $file ]
then
new_file=echo $file|sed -e 's/a\(.*\)/b\1/'
if [ -n $new_file ]
then
mv $file $new_file
fi
fi
done
Top




