FILE -ef FILE (conditional operator)

true if file1 is a hard link to file2, i.e. if it refers to the same device and inode numbers.

-ef is not included in POSIX. Avoid it if you want to stay compatible with POSIX shells.

Examples

Different ways to test if a file is a hard link to another file:
1
2
3
4
test ~/file1.txt -ef ~/file2.txt && echo "hard link"
[ ~/file1.txt -ef ~/file2.txt ] && echo "hard link"
# Bash
[[ ~/file1.txt -ef ~/file2.txt ]] && echo "hard link"
BashSupport Pro is a Bash IDE with support for -eftry it now!
© 2020–2024 Joachim Ansorg
Imprint
Privacy Policy
Legal