|
|
|
||||
|
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. |
![]() |
|
|||||||
| Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed. |
|
|
Thread Tools |
|
|
#1 |
|
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 Code:
cp: copying multiple files, but last argument `/var/www/dir2/myfile.txt' is not a directory I also tried Code:
cp /var/www/dir0/myfile.txt /var/www/dir*/ Code:
cp: omitting directory `/var/www/dir0' also tried using the -r parameter. I am root on the server. what'chya say?
__________________
http://www.muslimmatrimonial.com/ |
|
|
|
|
|
#2 |
|
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 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 |
|
|
|
|
|
#3 |
|
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' 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 |
|
|
|
|
|
#4 |
|
making it rain
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... |
|
|
|