I follow Unix Tool Tip on Twitter and it is interesting that many of the tips that are posted are not available on OS X.

For example:

cp - u will only copy files that don't exist, or are newer than their existing counterparts, in the destination directory.

Trying this on my machine results in:

cp: illegal option -- u
usage: cp [-R [-H | -L | -P]] [-fi | -n] [-apvX] source_file target_file
   cp [-R [-H | -L | -P]] [-fi | -n] [-apvX] source_file ... target_directory  

Why are these options not available and is it possible to get access to them on OS X?

  • You can also install find, sed, and awk with brew install coreutils findutils gnu-sed gawk. See apple.stackexchange.com/questions/69223/….
    – Lri
    Commented May 9, 2013 at 15:50
  • 2
    Warning: if you install and use the GNU versions of cli tools, you gain GNU's extensions, but you also lose the extensions in OS X's version of the tools. For example, the cp command in homebrew's coreutils (named gcp to avoid confusion) doesn't know how to copy the complex metadata that OS X files can have (extended attrs, etc); so if you use gcp on an alias file, the copy will be missing critical info and will not work. Commented May 11, 2013 at 23:05
  • @GordonDavisson thanks for the heads up. Is that the .file that gets added go all my directories? I think that may be a plus :)
    – DQdlM
    Commented May 11, 2013 at 23:40
  • @KennyPeanuts: Do you mean the .DS_Store file? That's similar but not what I'm talking about (and gcp -R will copy it along with everything else). If you mean ._somefilename, that's an AppleDouble file used to store metadata (the info I'm talking about) on some kinds of foreign volumes, which is ... complicated... Commented May 12, 2013 at 1:32
  • 2
    MacOS behaves like BSD, not GNU. Commented Dec 20, 2020 at 23:16

2 Answers 2


Get homebrew and have it install the core utilities. You can then see if the GNU version of cp supports the flags you desire. Here is a good answer on a partner site and I'll excerpt the exact steps you'll need to have cp be replaced by the GNU version if you wish:

Here's homebrew - Link
Here's the long story - https://superuser.com/questions/476575/replace-os-xs-shell-commands-with-the-linux-versions/476594#476594

An example of such an environment is Homebrew which for example has GNU sed among other things. Once you've installed Homebrew, you can type

brew install coreutils

and install the GNU Coreutils. These will provide you with sed, date, printf, wc and many other tools that ship with GNU/Linux, but not OS X. However, so as not to "override" default OS X binaries, they will be prefixed with g by default. So, after installing the Coreutils, if you want to use GNU sed, type


If this is too much of a hassle to type every time, you can add a "gnubin" directory to your PATH and just call GNU sed with sed. You will need to add the following to your ~/.bash_profile:

PATH="$(brew --prefix coreutils)/libexec/gnubin:$PATH"

  • 1
    Is it okay to install using port? Commented May 28, 2015 at 19:44
  • 2
    @AdilSoomro macports.org is a longstanding tool with a good reputation. I see no reason to not try it - I just have no experience with it. I do use and contribute to homebrew and can put up with its warts and peculiarities.
    – bmike
    Commented May 28, 2015 at 20:25
  • @AdilSoomro Yes, MacPorts is highly recommended over other package managers as it was built by Apple engineers - sudo port install coreutils.
    – sfxedit
    Commented Sep 7, 2021 at 6:24

The reason is that OSX uses BSD command line tools and the Unix tool tip users are probably using Linux which uses GNU command line tools.

You can install GNU tools on OSX (and BSD on Linux).

The easiest way is to use a package manager like Macports, Homebrew or Fink

You must log in to answer this question.

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