下面是逐行比较两个文件的脚本代码。希望大家多多提建议。
- #!/bin/bash
- CurRow=1
- LastRow=`cat file1 | wc -l`
- while [ $CurRow -le $LastRow ]
- do
- for x in `awk 'NR=='$CurRow' {print $0}' file1`
- do
- for y in `awk 'NR=='$CurRow' {print $0}' file2`
- do
- if [ "$x" == "$y" ];then
- echo "$x" >>result.txt
- fi
- done
- done
- ((CurRow++))
- done