⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 file-comparison.sh

📁 Shall高级编程
💻 SH
字号:
#!/bin/bashARGS=2  # Two args to script expected.E_BADARGS=65E_UNREADABLE=66if [ $# -ne "$ARGS" ]then  echo "Usage: `basename $0` file1 file2"  exit $E_BADARGSfiif [[ ! -r "$1" || ! -r "$2" ]]then  echo "Both files to be compared must exist and be readable."  exit $E_UNREADABLEficmp $1 $2 &> /dev/null  # /dev/null buries the output of the "cmp" command.#   cmp -s $1 $2  has same result ("-s" silent flag to "cmp")#   Thank you  Anders Gustavsson for pointing this out.## Also works with 'diff', i.e.,   diff $1 $2 &> /dev/nullif [ $? -eq 0 ]         # Test exit status of "cmp" command.then  echo "File \"$1\" is identical to file \"$2\"."else    echo "File \"$1\" differs from file \"$2\"."fiexit 0

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -