Reputation: 453
I have a bunch of folders with different names on which I am trying to copy one file to . I am not sure on how to do that with a wildcard charachter. Can anyone please help me out on this? So far I am stuck with this command
cp -R custom.css
As you can see I am trying to copy custom.css to all directories. Thanks!!
Upvotes: 0
Views: 65
Reputation: 247220
for all subdirectories recursively:
find . -type d -execdir cp /full/path/to/custom.cs . \;
Upvotes: 0
Reputation: 453
Nevermind I got it. This is what I did
for d in ~/Desktop/menus/*/ ; do cp custom.css $d; done
Upvotes: -1
Reputation: 786289
A simple for loop:
for d in path/to/dir1/ path/to/dir2/ path/to/dir3/; do
cp custom.css "$d"
done
EDIT:: Run this from parent directory to copy a file to all the subdirectories:
for d in */; do
cp custom.css "$d"
done
Upvotes: 2
Reputation: 221
First, get used to loops in (let's assume you are using) bash. Try creating 3 test directories, say d1, d2, and d3.
Try:
for d in d1 d2 d3; do echo $d; done
to make sure you have the list correct, then do:
for d in d1 d2 d3; do cp custom.css $d/; done
to copy your file.
Now check to make sure the file was copied.
O.k., now that it works, copy the file to your actual directories.
Upvotes: 0