Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to copy path of one file, but the directory isn't open in Finder, it is opened in terminal. Is it possible by invocation <utility> filename to copy full file path string to the Mac OS clipboard? Like copying the output of the following command there.


Added the following line to my .zshrc

function cn { echo -n $(pwd)/$1 | pbcopy }

Just aliasing don't work because of arguments. Exact same string should work in bash too.

share|improve this question
up vote 3 down vote accepted
echo $(pwd)/filename | pbcopy

This will give you a non-quoted and non-escaped string, which, depending on your use case, may not work properly when pasted elsewhere.

share|improve this answer
pbcopy is just what I need, will accept this answer as soon it will become possible, thank you. – eiennohito Jul 29 '13 at 14:13

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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