I have a script that creates a couple of files in the /tmp directory

touch /tmp/file1.txt
touch /tmp/file2.txt

How can I make the script open the /tmp/ directory in Finder with the two files file1.txt and file2.txt selected?

I know I can open the folder with:

open /tmp/

But it (obviously) doesn’t select the two files.

  • @JakeGould Not sure the post-edit title is asking the right thing: I don't want to open files that are already selected in Finder, I want to open Finder with specific files selected.
    – Xiao
    Dec 7, 2015 at 3:27
  • Tried to make it clearer. Your original question was confusing and not in a format that Stack Exchange likes with the colon (“:”) in the title. I think it’s clearer now but you know… It’s your question so feel free to adjust as you see fit. Dec 7, 2015 at 3:42
  • 1
    No, I think it's clearer now too. It was just the 'for selected files' that was a tad misleading. Thanks!
    – Xiao
    Dec 7, 2015 at 4:36

1 Answer 1


Look at the man page for the open(1) command: x-man-page://1/open

There you'll find the -R option:

-R  Reveals the file(s) in the Finder instead of opening them.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.