Welcome to the GoFuckYourself.com - Adult Webmaster Forum forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Post New Thread Reply

Register GFY Rules Calendar
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >
Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed.

 
Thread Tools
Old 10-23-2006, 12:19 AM   #1
Naja-ram
Confirmed User
 
Join Date: Aug 2006
Location: Iran
Posts: 639
any sysadmins up? shell question:

I have a file I want to copy to a few directories at once.
the file is located in /var/www/dir0/myfile.txt and I want to copy it to the following:
/var/www/dir1/
/var/www/dir2/
/var/www/dir3/
/var/www/dir4/

so I tried to use:
Code:
cp /var/www/dir0/myfile.txt  /var/www/dir*/myfile.txt
I got:
Code:
cp: copying multiple files, but last argument `/var/www/dir2/myfile.txt' is not a directory
it is.

I also tried
Code:
cp /var/www/dir0/myfile.txt /var/www/dir*/
and got:
Code:
cp: omitting directory `/var/www/dir0'
ofcourse I tried things like cp /var/www/dir0/myfile.txt /var/www/dir[0-9]/

also tried using the -r parameter.



I am root on the server.

what'chya say?
Naja-ram is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 10-23-2006, 12:40 AM   #2
PussyTeenies
Confirmed User
 
Join Date: Feb 2005
Location: Haarlem and Amsterdam, capital of the porn world ;-)
Posts: 6,496
use

Code:
for i in $(ls -1d /var/www/|grep -v dir0); do cp /var/www/dir0/myfile.txt /var/www/$i;done
breakdown

you make a listing of all directories except dir0
then you copy the mytext to all directories found ;)
__________________
Need adult hosting?

Contact us!
WARM Hosting

Need an IT solution? or someone to check your site and security? Nossie - IT Professional
PussyTeenies is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 10-23-2006, 12:41 AM   #3
PussyTeenies
Confirmed User
 
Join Date: Feb 2005
Location: Haarlem and Amsterdam, capital of the porn world ;-)
Posts: 6,496
ah and

Code:
cp: omitting directory `/var/www/dir0'
thats just that you are trying a copy to a allready copying directory ;)

hence the grep -v dir0 part in my anwser
__________________
Need adult hosting?

Contact us!
WARM Hosting

Need an IT solution? or someone to check your site and security? Nossie - IT Professional
PussyTeenies is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 10-23-2006, 12:45 AM   #4
fuzebox
making it rain
 
fuzebox's Avatar
 
Industry Role:
Join Date: Oct 2003
Location: seattle
Posts: 22,138
I'd do this:

foreach `ls -d /var/www/dir?`;do cp /var/www/dir0/myfile.txt $i;done

It'll throw up an error about /var/www/dir0 that you can ignore.

At least this works in most installations...
fuzebox is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Post New Thread Reply
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >

Bookmarks



Advertising inquiries - marketing at gfy dot com

Contact Admin - Advertise - GFY Rules - Top

©2000-, AI Media Network Inc



Powered by vBulletin
Copyright © 2000- Jelsoft Enterprises Limited.