SwimBikeRun
SwimBikeRun

Reputation: 4460

Understanding cp in shell script

 cp ${skeleton_dir}/*.cfg ${skeleton_dir}/*.org ./

I don't understand what this means, but I have a guess based on the program behavior. It copies the .cfg files to the current directory, but what does the *.org ./ do?

I want to modify this line to copy *.spop files as well. Will this change do the trick? (It is hard to verify this easily as the turnaround time on my machine is a day)

 cp ${skeleton_dir}/*.cfg ${skeleton_dir}/*.org ./
 cp ${skeleton_dir}/*.spop ${skeleton_dir}/*.org ./

Sorry for the stupid questions, but I don't know much about this, and it is difficult to google for "./".

In the future, how would I search for the different variations used with the cp command (this "./"). I know about "man xxx" now, and I read "man cp", but nothing was in there about "./"

Upvotes: 1

Views: 7576

Answers (1)

Explosion Pills
Explosion Pills

Reputation: 191749

If you read the man page for cp, you will see that you can specify multiple sources to copy to a target directory. ./ is the current directory. So what this does is copy all .cfg and .org files in ${skeleton_dir} to the current directory. Simply add *.spop:

cp ${skeleton_dir}/*.cfg ${skeleton_dir}/*.org ${skeleton_dir}/*.spop ./

You could also use brace expansion:

cp ${skeleton_dir}/*.{cfg,org,spop} ./

Upvotes: 1

Related Questions