两个文件节点号都为262154,是硬链接
创建硬链接
两个文件直接进行比较
```sh
eric@rpi4b:~ $ ls -ali | grep test
24553 -rw-r--r-- 1 eric eric 411 9月 21 11:37 nvm_echo_test.sh
30221 -rwxr-xr-x 1 eric eric 172 9月 21 18:03 shell-env-variable-test.sh
24592 -rwxr-xr-x 2 eric eric 156 9月 21 13:15 test-hard-link.sh
24592 -rwxr-xr-x 2 eric eric 156 9月 21 13:15 test.sh
23662 lrwxrwxrwx 1 eric eric 7 10月 8 16:44 test-soft-link.sh -> test.sh
eric@rpi4b:~ $
```

```sh
$ ls -alth
$ ls -i
```

ln 硬连接
ln -s 软连接 ✅ --soft
```sh
# -ef => --equal --file
# 文件相等比较,检测文件是否是一个软链接 ✅
[ ./student.sh -ef ./soft ] && [ -L ./soft ] && echo yes || echo no
[ ./student.sh -ef ./hard ] && [ -L ./hard ] && echo yes || echo no
```
https://github.com/xgqfrms/linux-shell-script-programming/assets/7291672/94ce2289-e74a-4f69-a33a-54dee716ae04

https://www.imooc.com/qadetail/337388
inode

ln /root/student.txt /tmp/shu.tt #给student.txt创建硬链接

两个文件之间的比较
测试选项 作用
文件1 -nt 文件2 判断文件1的修改时间是否比文件2的新(如果新则为真)
文件1 -ot 文件2 判断文件1的修改时间是否比文件2的旧(如果旧则为真)
文件1 -ef 文件2 判断文件1是否和文件2的Inode号一致,可以理解为两个文件是否为同一个文件。这个判断用于判断硬链接是很好的方法
举例:
ln /root/student.txt /tmp/stu
[ /root/student.txt -ef /tmp/stu ] && echo "yes" || echo "no"
做两个文件的比较
两个文件之间的比较
两个文件之间的比较
文件之间的判断
两个文件之间进行比较
两个文件进行比较。
比较两个文件用到的三个选项:“-nt”“-ot”“-ef”
两个文件之间的比较
先把/root/student.txt 链接到/tmp/stu.txt .然后判断这两是否为同一文件
文件比较