在 diff 命令中出现以下错误。请协助我如何指定我想看到两个文件的区别:
#current_unavail=ranjith
root@iitmserver1 tmp]# cat /tmp/ran
ranjith
[root@iitmserver1 tmp]#
#test=$(cat /tmp/ran)
[root@iitmserver1 tmp]# diff `$current_unavail` `$test`
diff: missing operand after `diff'
diff: Try `diff --help' for more information.
[root@iitmserver1 tmp]#
最佳答案
diff
将两个文件名 作为参数,您似乎将文件内容 作为第一个参数传递。你会想要改变你的脚本/命令看起来更像:
current_unavail=/tmp/unavail_cn.out
result=$(diff $current_unavail /moes/home/pharthiphan/scripts/monitoring/unavail_cn/$last_unavail)
或者,您可以使用 Process Substitution将一个命令的输出传递给另一个需要文件的命令。例如:
diff <(echo -e "foo\nbar") <(echo -e "foo\nbaz")
但是,虽然很高兴了解这一点,但对于您当前的问题来说,这似乎是不必要的复杂程度。
关于linux - diff 命令不工作 "missing operand after ` diff'",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29633449/