Search code examples
unixcpdollar-sign

Unix `cp` command with $ sign


This question is regarding the Unix cp command.

What is the $(...) operator doing below?

cp $(bundle show bootstrap-sass)/vendor/assets/stylesheets/bootstrap.scss \ app/assets/stylesheets/bootstrap-custom.scss

I came across this notation from the page: https://github.com/twbs/bootstrap-sass#usage

I checked the man page for cp and did not see any references to this operation. I'm new to *nix. Thanks.


Solution

  • In shell scripting, the $(...) executes the commands in the parenthesis and returns the text printed to STDOUT by that command. This also applies to the backtick notation as well.

    For example: echo $(date) - This is a dated line will print something like Thu Jun 26 10:08:20 CDT 2014 - This is a dated line

    Here's another Stack Overflow question on the topic.