If I understand what you're trying to do (essentially, the equivalent of selecting a file in Finder and choosing Edit menu > Copy), this should work:
osascript -e 'on run argv' -e 'set the clipboard to item 1 of argv as «class furl»' -e 'end run' /path/to/file
Note that I don't think this'll work with relative paths or bare filenames. If you want to make this into a script or function, you should probably add a step to convert relative paths to asolute... which is tricky on macOS since it doesn't have realpath
and its readlink
doesn't have the -f
option. See "How to retrieve absolute path given relative" and the linked duplicate questions.
Also, for completeness, if you just want to copy the contents of a file as text, it's much easier: pbcopy </path/to/file