所以,我的节目:
#!/bin/bash
OIFS="$IFS"
IFS=$'\n'
find teste1 -type f | while read -r firstResult
do
find teste2 -type f | while read -r secondResult
do
firstName=${firstResult##*[/|\\]}
secondName=${secondResult##*[/|\\]}
if [[ "$( echo "$firstName" | tr [A-Z] [a-z])" == "$( echo "$secondName" | tr [A-Z] [a-z])" ]]; then
echo "$firstResult" "$secondResult" >> equal.lst
else
echo "$firstResult" "$secondResult" >> notEqual.lst
fi
if [[ $firstName == $secondName ]]; then
echo "$firstResult" "$secondResult" >> equal2.lst
fi
done
done
diff -2 equal.lst equal2.lst >> renamedFiles.lst
我在'diff'部分遇到一些困难,因为'renamedFiles.lst'的输出显示如下:
3D2 < teste1 \ TESTE.pub teste2 \ TEstE.pub
8D6 < teste1 \ TeStE2.xlsx teste2 \ testE2.xlsx
所以我的问题是:如何删除“3d2”和“8d6”部分?我有办法这样做吗?我想为这些差异创建一份报告,如果它没有这些数字,它会更“清洁”。我知道为什么数字存在,但有没有办法将其删除?
答案 0 :(得分:1)
使用线条格式指定所需的确切格式。例如:
diff -2 "--old-line-format=<%L" "--new-line-format=>%L" "--unchanged-line-format=" equal.lst equal2.lst
结果为裸输出,如:
>new line
<old line