What does "-f" option do for "find" on FreeBSD?

Hello, there:
I'm now learning command line from scratch on FreeBSD, and now there's a problem relating to "find" confusing me. In "find" manual, it introduces the "-f" option with following description:

Code:
-f      Specify a file hierarchy for find to traverse.  File hierarchies
             may also be specified as the operands immediately following the
             options.

However, there's no further guide and example for that. I tried it myself with these output:

Code:
[color="DarkGreen"]justin@zust.pts/0 ~ %[/color] ls test/mydoc/myfile/
myfile mytime myway
[color="#006400"]justin@zust.pts/0 ~ %[/color] find test/mydoc/myfile/ -type f -iname "*way*"
test/mydoc/myfile/myway
[color="#006400"]justin@zust.pts/0 ~ %[/color] find -f ~/test/mydoc/myfile -type f -iname "*way*"
find: illegal option -- t
find: illegal option -- y
find: illegal option -- p
find: illegal option -- e
/home/justin/test/mydoc/myfile/myway
[color="Red"]find: f: No such file or directory[/color]
[color="#006400"]justin@zust.pts/0 ~ %[/color] find -f ~/test/   mydoc/myfile -type f -iname "*way*"
/home/justin/test/mydoc/myfile/myway
[color="#ff0000"]find: mydoc/myfile: No such file or directory[/color]
[color="#006400"]justin@zust.pts/0 ~ %[/color] find -f ~  /test/mydoc/myfile -type f -iname "*way*"
/home/justin/Art/music/Secret Garden/Always There.mp3
/home/justin/Download/11.A Thousand Miles Away.mp3
/home/justin/Download/12.Gifts Along The Way.mp3
/home/justin/Download/14.Always Near.mp3
/home/justin/Personal_University/其它/The_Open_Source_Way.pdf
/home/justin/.goldendict/WyabdcRealPeopleTTS/a/always.wav
/home/justin/.goldendict/WyabdcRealPeopleTTS/a/anyway.wav
/home/justin/.goldendict/WyabdcRealPeopleTTS/a/away.wav
/home/justin/.goldendict/WyabdcRealPeopleTTS/b/breezeway.wav
/home/justin/.goldendict/WyabdcRealPeopleTTS/d/doorway.wav
/home/justin/.goldendict/WyabdcRealPeopleTTS/f/freeway.wav
/home/justin/.goldendict/WyabdcRealPeopleTTS/g/gangway.wav
/home/justin/.goldendict/WyabdcRealPeopleTTS/g/gateway.wav
/home/justin/.goldendict/WyabdcRealPeopleTTS/h/hallway.wav
/home/justin/.goldendict/WyabdcRealPeopleTTS/h/headway.wav
/home/justin/.goldendict/WyabdcRealPeopleTTS/h/highway.wav
/home/justin/.goldendict/WyabdcRealPeopleTTS/l/leeway.wav
/home/justin/.goldendict/WyabdcRealPeopleTTS/m/motorway.wav
/home/justin/.goldendict/WyabdcRealPeopleTTS/r/railway.wav
/home/justin/.goldendict/WyabdcRealPeopleTTS/r/roadway.wav
/home/justin/.goldendict/WyabdcRealPeopleTTS/s/sideways.wav
/home/justin/.goldendict/WyabdcRealPeopleTTS/s/slantways.wav
/home/justin/.goldendict/WyabdcRealPeopleTTS/s/stairway.wav
/home/justin/.goldendict/WyabdcRealPeopleTTS/s/stowaway.wav
/home/justin/.goldendict/WyabdcRealPeopleTTS/s/subway.wav
/home/justin/.goldendict/WyabdcRealPeopleTTS/s/sway.wav
/home/justin/.goldendict/WyabdcRealPeopleTTS/w/way.wav
/home/justin/.goldendict/WyabdcRealPeopleTTS/w/waylaid.wav
/home/justin/.goldendict/WyabdcRealPeopleTTS/w/waylay.wav
/home/justin/.goldendict/WyabdcRealPeopleTTS/w/wayward.wav
/home/justin/.lyrics/Always There.lrc
/home/justin/.icons/Macbuntu-Icons/status/24/user-away.png
/home/justin/.icons/Macbuntu-Icons/status/24/user-away-panel.png
/home/justin/.icons/Macbuntu-Icons/status/24/empathy-away.png
/home/justin/.icons/Macbuntu-Icons/status/24/empathy-extended-away.png
/home/justin/.icons/Macbuntu-Icons/status/22/user-away.png
/home/justin/.icons/Macbuntu-Icons/status/22/user-away-panel.png
/home/justin/.icons/Macbuntu-Icons/status/22/empathy-away.png
/home/justin/.icons/Macbuntu-Icons/status/22/empathy-extended-away.png
/home/justin/.icons/Macbuntu-Icons/status/16/user-away.png
/home/justin/.icons/Macbuntu-Icons/status/16/user-away-panel.png
/home/justin/.icons/Macbuntu-Icons/status/16/empathy-away.png
/home/justin/.icons/Macbuntu-Icons/status/16/empathy-extended-away.png
/home/justin/.icons/Macbuntu-Icons/apps/scalable/kopete_some_away.png
/home/justin/.icons/Macbuntu-Icons/apps/scalable/kopete_all_away.png
/home/justin/test/mydoc/myfile/myway
[color="#ff0000"]find: /test/mydoc/myfile: No such file or directory[/color]

So, could you help me, please? Thank you in advance. :p
 
Verified. Option parsing bug, I'd say. A quick check didn't find this in the PR database, but it might not be in find(1) itself.

Code:
% find -f /usr/ports -name Makefile -exec grep -H REINPLACE {} \+ | less
find: illegal option -- n
find: illegal option -- a
find: illegal option -- m
find: illegal option -- e
/usr/ports/lang/otcl/Makefile:  @${REINPLACE_CMD} -e 's|/usr/X11R6|${LOCALBASE}|g' \
/usr/ports/lang/otcl/Makefile:  @${REINPLACE_CMD} -e 's|../lib/tcl$$TCL_HI_VERS|${TCL_LIBDIR}|g' \
/usr/ports/lang/otcl/Makefile:  @${REINPLACE_CMD} -e 's|../lib/tk$$TK_HI_VERS|${TK_LIBDIR}|g' \

Please enter a PR.
 
It is strange that find does not abort when it sees an invalid option, but I think your command is incorrect anyway.

The things like "-print" are operands, not options and therefore some sort of separation is required so that they are not seen as options. This can be the "--" end of options marker, a non-"-f" pathname or an "!" or "(" operand.

If you do not want to use "-f" because it is not portable, prepend "./" to any pathnames that start with "-" or are "!" or "(". Note that this prepending is reflected in the output.
 
The synopsis in find(1) doesn't show a --, and the examples don't use -f at all. Maybe this is a regression that few have noticed since the -f is rarely used.
 
Back
Top