I messed up pbcopy. Instead of

 cat foo | pbcopy

I did

  cat foo > pbcopy

And now my pbcopy is a text file. How can I reinstall it? Is it a part of some specific package, maybe something in homebrew?

  • What OS do you have? I could just put mine up on Dropbox. I do run 10.8.5 and 10.7.4 so not the latest OS version though. Oh, you really where in /usr/bin directory at the time running that command? – boretom Jan 2 '14 at 8:56

Unless you ran these commands in the directory /usr/bin, and with root privileges, you have not overwritten the real pbcopy - you've simply created a new file in your current working directory with the same name.

So - you most likely do not have to reinstall pbcopy. To verify, you can call the full program explicitly, like this:

cat foo | /usr/bin/pbcopy

which should work properly. If it does, you can delete the pbcopy you inadvertently created safely...

  • Unfortunatelly, I was root at that time... – Adrian Jan 2 '14 at 6:04
  • @Adrian Ouch. Next time you are heading into root, you can issue tmutil snapshot to set a local snapshot of files if you have a local Time Machine destination. It won't help you now unless you already have a backup, but it's nice to have a rollback safety net when you are root. – bmike Jan 2 '14 at 7:52
  • 1
    → Adrian: if you were root but not within the /usr/bin directory, the analysis of Scot stands. I advise you to check it. – dan Jan 2 '14 at 10:44

The pbcopy binary comes from the OS X base installation and you can restore it from Time Machine (either a local snapshot or an external drive) will have copies of that file.

Next, you could open the installer in a program like Pacifist and extract that binary.

Worst case, rerun the installer or get a copy of the binary from a trusted source and you should be good to go as long as the source is the same level as your OS.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .