The readlink utility on recent macos versions (I'm on ventura) support the "-f" switch, but that has not always been the case. I note, for example, that it's NOT present on 11.6. Which was the first version of macOS to support this?
1 Answers
The earliest version where readlink -f appears in man pages is macOS Monterey 12.3.
The following excerpts were taken from the stat.1 file for macOS 12.2.
SYNOPSIS
readlink [-n] [file ...]
DESCRIPTION
When invoked as readlink, only the target of the symbolic link is printed. If the given argument is not a symbolic link, readlink will print nothing and exit with an error.
The following excerpts were taken from the stat.1 file for macOS 12.3.
SYNOPSIS
readlink [-fn] [file ...]
DESCRIPTION
When invoked as readlink, only the target of the symbolic link is printed. If the given argument is not a symbolic link and the -f option is not specified, readlink will print nothing and exit with an error. If the -f option is specified, the output is canonicalized by following every symlink in every component of the given path recursively. readlink will resolve both absolute and relative paths, and return the absolute pathname corresponding to file. In this case, the argument does not need to be a symbolic link.
How to Verify This Answer
The output below is from macOS Catalina 10.15.7.
- Enter to command
man -w readlinkto determine the file name of the man page to download. The output is shown below./usr/share/man/man1/stat.1 - Enter the command
which readlinkto get the full path to the command. The output is below./usr/bin/readlink - Use the full path to enter the command
what /usr/bin/readlink. The output (shown below) can be adapted to find the appropriatestat.1file./usr/bin/readlink PROGRAM:stat PROJECT:file_cmds-287.100.2 - Goto Apple Open Source Releases to download the appropriate
stat.1file for the desired version of macOS. - Enter the command
man ~/Downloads/stat.1to view the formatted version of thestat.1file.
- 40,244
-fisfile_cmds-353.100.22, better known as macOS 12.3 :-) OTOH, thereadlinkfunctionality was present long before there was a man page for it (already in Tiger). – nohillside Sep 11 '23 at 17:36readlink. I am not sure if you are saying Tiger has or does not have a man page forreadlink. I downloadedstat.1for OS X Tiger 10.4 and foundreadlink. So I think there is a man page in Tiger forreadlink. – David Anderson Sep 12 '23 at 01:02