Phil Scarratt wrote:
Phil Scarratt wrote:

Hi all

Just wondering what people come up with as far as the easiest way to create a sub-directory under all users home directory with appropriate permissions. In the order of 400 users, with approx 50 in one primary group and the rest in another primary group. Permissions need to be 700.


Just had a flash of inspiration:


find /home/ -type d -maxdepth 1 | perl -nle 'system("mkdir $_/newdir");'
chown --reference=/home/* /home/*/newdir

Would this work? If so I'm sure there'd be a more concise method? in one step maybe?

Fil


Flash of inspiration was almost right....had to modify the second command to:


find /home/ -type d -maxdepth 1 | perl -nle 'system("chown --reference=$_ $_/newdir");'

which means

find /home/ -type d -maxdepth 1 | perl -nle 'system("mkdir $_/newdir");system("chown --reference=$_ $_/newdir");'

would work as one command.

Still interested in other methods though....

Fil


-- SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/ Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html

Reply via email to