copying file/folder into subdirectories
I have over 50 folder in home (using Debian 6 LAMP).
/home/xcz1/xzcx2/name1/name2 /home/zsd1/zd2/name1/name2 /home/.../.../name1/name2 ... /home/update/name2/ how can i copy the name2 from update folder and paste him into the name1 folder of each folder in the home folder? i have tried: cd /home/update cp -R name2 /home/*/*/name1 and cp -r name2 /home/../../name1 but it did not work. Thank's |
Your request (or at least the way you are explaining it) is somwhat odd, and a bit vague or ambiguous. Can you perhaps give us some more background on what you are trying to accomplish?
|
Quote:
These files are not there, so overwrite is not needed. or as simple as possible: It's game hosting machine, these 50 folders contain the files and folders of the game, so i want to input some files, which block exploits and etc. how i gonna do it? Sorry for my bad English. |
If i understand you correctly, you want to copy ~/src/dir/file to ~/dst/dir/file
Could the problem be that the ~/dst/dir/ folder doesent exist? In that case you could either just mkdir ~/dst/dir/ or do some fancy find thing. |
Quote:
All directories has been already created, but i need files on the right position, so i want input them to one directory named as 'dir' and input them (whole 'dir' folder) in an subdirectory where is the directory with name 'dir'. But i don't want input it in just one directory, i want input it in all directory in the 'home' dir. (all those directories have created 'dir' directory). for example: /home/michael/today/dir /home/carey/evening/dir /home/jay/birthday/dir and i want input 'dir' folder from /home/update/dir to those above. (Please do not tell me, i have to do it one by one, it must be some trick with 'cp' command or something like that. |
I don't know if there is a single command that can do that, but I think something like this shell script should work:
Code:
XYZ=`ls /home/*/*/dir -d` Code:
. Code:
|-- home |
You will need to use a loop.
Code:
for dir in /home/*/*/dir1; do |
Quote:
./mcopy.sh it's work, but when finish show this error: p: missing destination file operand after `/home/update/dir/subdirectory' Try `cp --help' for more information. It's not so mather, beacause it's work :D Thank you. Quote:
Thank's anyway. |
name2 is from your original post. I didn't enter a script to run but an example of the commands to run in the terminal.
Since you are copying into several users' home directories, you will need to run the cp command as root. 1) The first argument of cp is the file to copy. If you are copying a directory, then use the -r flag. It is to recurse through the source, not the destination. Be in the same directory as the source file, or include the path to it in the filename. 2) Wildcards are expanded before the command is run. /home/*/*/dir1 will expand to a list of directories named "dir1" two levels deep from each users home directory. Such as /home/mike/www/dir1/ for example. I think it would be better to explicitly give which directory it is, and use a variable for the user name: Code:
for user in sam mike sally ted; do Code:
for homedir in /home/*; do need, and watch what you do. |
All times are GMT -5. The time now is 07:51 PM. |