Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.syntblaze.com/llms.txt

Use this file to discover all available pages before exploring further.

The -ef (equivalent file) operator is a binary file test operator in Bash that evaluates whether two paths refer to the identical physical file on the filesystem. It returns a true (0) exit status if and only if both files exist and possess the exact same device number (st_dev) and inode number (st_ino).
[ FILE1 -ef FILE2 ]
[[ FILE1 -ef FILE2 ]]
test FILE1 -ef FILE2

Technical Behavior

  • System-Level Evaluation: The operator relies on the underlying stat() system call. It does not perform byte-by-byte content comparison or string-based path comparison. It strictly compares the filesystem metadata (st_dev and st_ino fields).
  • Symbolic Link Dereferencing: The -ef operator automatically resolves (dereferences) symbolic links. If FILE1 is a symlink pointing to FILE2, the operator evaluates the inode of the resolved target, resulting in a true evaluation.
  • Hard Link Resolution: Because hard links are multiple directory entries pointing to the same inode on the same filesystem, comparing two distinct hard link paths of the same file with -ef will evaluate to true.
  • Non-Existent Files: If either FILE1 or FILE2 does not exist, or if either path resolves to a broken symbolic link, the operator evaluates to false (1) without throwing a syntax error.
Master Bash with Deep Grasping Methodology!Learn More