linux shell比较两个文件夹下的文本内容
来源:互联网 发布:心彻为知 知彻为德出自 编辑:程序博客网 时间:2024/04/30 01:53
#!/bin/sh
if [ $# -ne 2 ]
then
echo Usage: compare.sh fold_name_1 fold_name_2
exit
fi
if [ ! -d $1 ]
then
echo $1 is not a
exit
fi
if [ ! -d $2 ]
then
echo $2 is not a
exit
fi
fold1=$(echo $1 | sed 's|\(^[^/]*\).*|\1|')
fold2=$(echo $2 | sed 's|\(^[^/]*\).*|\1|')
compareFOLD()
{
for file in $1/*
do
if [ -d $file ] then
compareFOLD $file
elif [ -f $file ]
then
if [ ! -L $file ]
then
file2=$(echo $file | sed "s|^.[^/]*\(.*\)|$fold2\1|")
diff $file $file2
if [ $? -ne 0 ]
then
echo -e "\033[32m"$file
echo $file2
echo -e "\033[0m"---------------------------------------------------------------------
fi
fi
fi
done
}
compareFOLD $fold1
if [ $# -ne 2 ]
then
echo Usage: compare.sh fold_name_1 fold_name_2
exit
fi
if [ ! -d $1 ]
then
echo $1 is not a
exit
fi
if [ ! -d $2 ]
then
echo $2 is not a
exit
fi
fold1=$(echo $1 | sed 's|\(^[^/]*\).*|\1|')
fold2=$(echo $2 | sed 's|\(^[^/]*\).*|\1|')
compareFOLD()
{
for file in $1/*
do
if [ -d $file ] then
compareFOLD $file
elif [ -f $file ]
then
if [ ! -L $file ]
then
file2=$(echo $file | sed "s|^.[^/]*\(.*\)|$fold2\1|")
diff $file $file2
if [ $? -ne 0 ]
then
echo -e "\033[32m"$file
echo $file2
echo -e "\033[0m"---------------------------------------------------------------------
fi
fi
fi
done
}
compareFOLD $fold1
0 0
- linux shell比较两个文件夹下的文本内容
- linux shell比较两个文件夹下的文本内容
- linux 比较两个文件夹下的内容
- Vim比较两个文本的内容
- shell怎么比较两个文件夹的差别
- shell脚本比较两个文件夹
- python 同步两个文件夹下的内容(包括子文件夹)
- 两个文件夹 的比较
- linux 下使用diff命令比较两个文件夹
- 文件输入输出 c++ 比较两个文本内容
- 比较两个txt文件内容的差异,分别在windows与linux环境下
- linux根目录下各文件夹 的内容
- linux shell 统计文件夹下的目录
- Linux Shell获取文件夹下的文件名
- shell脚本查找两个文件夹下相同的文件名
- java比较两个文件夹下的文件是否一致
- shell下处理文本内容的几个有效命令
- 比较两个文本的不同
- Aircrack-ng官方文档翻译[中英对照]---Airmon-ng
- iOS 升级至Xcode5后xib在iOS5.0下运行无法加载的问题
- Mysql 分页语句Limit用法
- JAVA静态方法是否可以被继承?
- 网格布局管理器gridbagconstraints 的设置随意宽度实例(四)
- linux shell比较两个文件夹下的文本内容
- 一张好图描述内存数据类型
- 数据分析的前途在哪? 职业发展之路?有什么资格认证证书吗?
- 杭电2023
- POJ 3371 Flesch Reading Ease (模拟题)
- 备忘:linux set 命令常见误用
- RSA算法原理(一)
- 链表总结1
- constraints.fill=GridBagConstraints.HORIZONTAL;