我想比较2个文件,如果它们改变就得到输出 我错过了什么
#!/bin/ksh
cd /tmp
FilesDiff=`diif -U 0 /tmp/file1 file2 |grep ^@ |wc -l`
countnew = `cat /tmp/file1 |wc -l`
countold = `cat /tmp/file2 |wc -l`
if $FilesDiff != 0 and countnew > countold
then
exit 0
else
exit 1
fi
答案 0 :(得分:1)
是的,你有拼写错误,在比较和一些间距错误周围缺少一些括号。修复它们,脚本将起作用:
#!/bin/ksh
cd /tmp
FilesDiff=`diff -U 0 /tmp/file1 file2 |grep ^@ |wc -l`
countnew=`cat /tmp/file1 |wc -l`
countold=`cat /tmp/file2 |wc -l`
if (($FilesDiff != 0)) && (($countnew > $countold))
then
exit 0
else
exit 1
fi