copy a file to multiple directories with *
[root@webmail mnt]# echo /home/*/public_html/ | xargs -n 1 cp -v read.html
‘read.html’ -> ‘/home/korbceramic/public_html/read.html’
‘read.html’ -> ‘/home/serverfix/public_html/read.html’
‘read.html’ -> ‘/home/suntouchpolypack/public_html/read.html’
‘read.html’ -> ‘/home/vabopaliya/public_html/read.html’
[root@webmail mnt]# cd /home/korbceramic/public_html/
reminder this will replace the prev file and copy newer ones
While copying file to 2-3 directories, you can do it easily with multiple commands. But think, if you have to copy this to large number of directories at a time. For example, I have a WHM/cPanel server with large number of account and want to place a file to each accounts public_html directory. We can do this in single command as:
Comments
Post a Comment