LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 10-28-2007, 11:49 PM   #1
leebrent
Member
 
Registered: Oct 2007
Location: Nanaimo
Distribution: Red Hat 5
Posts: 39

Rep: Reputation: 15
Creating Multiple Directories in the same location in user space


Hello,

I am stumped with trying to solve the following problem:

I have directory structure that looks like the following:

/home/username1/public_html/
...
/home/username999/public_html/

If I want to create a /upload directory in all of the user folders with one command, what command should I be using?

I am currently trying to use:

mkdir /home/*/public_html/upload

Any ideas or suggestions would be greatly appreciated.

Cheers,

Brent
 
Old 10-29-2007, 12:11 AM   #2
Simon Bridge
LQ Guru
 
Registered: Oct 2003
Location: Waiheke NZ
Distribution: Ubuntu
Posts: 9,211

Rep: Reputation: 198Reputation: 198
You going to need a script - generate a list of usernames and get the script to step through them.
 
Old 10-29-2007, 12:51 AM   #3
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
I hope this isn't a homework question.

sudo mkdir /home/username{1..9999}/public_html
If the usernameX directories don't exist,
sudo mkdir -p /home/username{1..9999}/public_html

If you are working from a list, (and you were generalizing the names) you can use
cat usernamelist | xargs mkdir

This isn't a single command, but it is an easy one-liner.

Last edited by jschiwal; 10-29-2007 at 01:03 AM.
 
Old 10-29-2007, 12:14 PM   #4
leebrent
Member
 
Registered: Oct 2007
Location: Nanaimo
Distribution: Red Hat 5
Posts: 39

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by jschiwal View Post
I hope this isn't a homework question.

sudo mkdir /home/username{1..9999}/public_html
If the usernameX directories don't exist,
sudo mkdir -p /home/username{1..9999}/public_html

If you are working from a list, (and you were generalizing the names) you can use
cat usernamelist | xargs mkdir

This isn't a single command, but it is an easy one-liner.
Thanks,

It is not a homework question.

I knew there was an easy way to do it, but it slipped my mind. Your command makes the most logical sense as I can make the lists from my database dumps using a list of all the users needing the folder.

Cheers,

Brent.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Multiple website on Apache with User Directories Mr_Oz Red Hat 2 01-16-2006 07:20 AM
Searching multiple directories and sub directories for a file jeep99899 Linux - Newbie 2 10-13-2005 12:23 PM
Creating Multiple user accounts from a formatted file collern2 Programming 2 03-09-2005 09:15 PM
Creating multiple users in Kmail with a single KDE user jonole Linux - Software 3 10-03-2004 12:36 AM
Creating user directories in Apache root robojerk Linux - Networking 1 09-21-2004 12:34 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 10:32 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration