Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Hello,
How to copy a directory in all directories of a directory.
For exemple, I've a home directory, with 500 user directories approximatly.
And I want to copy one directory in all of these user directories.
Thank you for your help.
Ted
So let me get this straight. You have a home directory with 500 user directories so:
Home>
>user1
>user2
to
>user500
and you want to copy 1 directory inside each user's directory to somewhere else. For instance say there is a folder called Tempfolder in all the users directories you would only want to copy that directory to another location?
Or do you want to know the command to copy say user1's directory and all the sub directories in it?
Thank you for your replies, sorry for my bad english.
I try to explain my problem, with details.
I'm using ubuntu server edition 7.10.
the forrestt's reply is near my problem.
The context :
The directory tree is like this :
/home/a/anton/myspace
/home/a/alphablondy/myspace
/home/b/beettlejuice/myspace
.
.
.
/home/z/zimbawe/myspace
So, in /home/master, there is a directory called 'config' (/home/master/config)
What I want to do :
I want to copy the /home/master/config, in all users 's myspace.
to get this :
/home/a/anton/myspace/config
/home/a/alphablondy/myspace/config
/home/b/beettlejuice/myspace/config
.
.
.
/home/z/zimbawe/myspace/config
Due to the system context, I can use python, shell, or pearl.
Sorry for my english, I hope that my explanations are clear.
I'm linux beginner.
Thank you for your help.
Regards
Last edited by tedtheinsane; 04-30-2008 at 02:35 AM.
#!/bin/sh
cd /home
for d in [a-z]; do # [a-z] to skip "/home/master"
for ud in d/*; do
user=${u##*/} # strip off "d/" (i.e. leave username)
cp -a /home/master/config $ud/myspace
# set owner:group from user's home dir
chown -R $(stat -c "%U:%G" $ud) $ud/myspace/config
done
done
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.