1

What does -ar flag mean here:

cp -ar ../foo/bar/. qux/quux/

I'm quite new to command line languages and trying my best to learn it.

Not sure of the -ar flag only. -r is recursive right, then can you just add -a and it becomes -ar? Does -a mean all?

2

Generally, multiple single letter flags can be combined into a single argument. In this case:

cp -ar ../foo/bar/. qux/quux/

is equivalent to:

cp -a -r ../foo/bar/. qux/quux/

If you look in the manual, it will tell you that -a is "same as -dR --preserve=all". You can look all of those up if you want, but the short version is that the -a flag causes the new files to have the same permissions, owner, timestamp, etc. as the original files. (Normally, they would be owned by the user performing the 'cp' with permissions defined by your shell configuration, and a current timestamp.)

  • Does -r and -R has any difference? – Nomadme Jun 3 '15 at 16:53
  • 1
    @Nomadme see unix.stackexchange.com/questions/18712/… - tl;dr: you should only use -R, not -r, because -r has non-portable (and often undesired) semantics for symbolic links and special files. But they're not different on Linux. – Random832 Jun 3 '15 at 17:39
  • @Random832, thank you for explaining that. I have been always using -r and will use -R now on. – Nomadme Jun 5 '15 at 13:14
2

It's two independent options - -a and -r. It is common practise for unix-like commands to use this "compact" options scheme if the options are boolean. Check man cp for what -a means.

  • Awesome, thanks for the direction. I completely forgot to use the "man". lol. I told you I'm newbie :) – Nomadme Jun 3 '15 at 15:48

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.