First thing is to open the app you want to see these files.
open -a TextEdit
Or Xcode or another app you know can open text files.
Once you have an app that opens, pass the file after the name of the app.
open -a TextEdit file.txt
Once that works, open the folder containing that text file and inspect the finder contextual menu and perhaps refresh the “Always open with” binding for that file type. You can use the
mdls commands to examine the file in case the .txt is not representative of the actual file type. Sometimes text files are not simply a text file, so check out these metadata keys:
kMDItemContentType = "public.plain-text"
kMDItemContentTypeTree = (
kMDItemKind = "Plain Text Document"
Lastly if open itself is throwing the error, I would check if there is an error code we can look at as well as the code signing is still correct for that:
/usr/bin/open -a Finder
codesign -vvvv -R="anchor apple" /usr/bin/open
The last should show a valid program passing all checks:
/usr/bin/open: valid on disk
/usr/bin/open: satisfies its Designated Requirement
/usr/bin/open: explicit requirement satisfied
You likely have a new open program in your path or a function - since you should not get the error you did Opening '-a TextEdit' ... as the
open program should parse the
-a switch and not spit it back to you...
% type open
open is /usr/bin/open