Copy single file to multiple locations - What am I doing wrong
Hi
I have a little server running qmail/plesk . The problem is my ISP wont support Spamassassin due to load issues on the host server and I cannot afford to migrate to a root server (using VMWARE at the mo). I have spamassassin installed manually but also need to use plesk for adding domains and I got it working. Problem is it is set up by default to rewrite_headers and accept the message. I need to reject it via the .qmail files. I have one .qmail file and I need to copy it over every users .qmail file. Here is what I am trying. Code:
However the cp command complains that /var/qmail/mailnames/*/.qmail is not a directory. I already know that and want to overwrite the file. if I omit the .qmail file and do cp ./.qmail /var/qmail/mailnames/*/ it returns a message like 'Omitting directory example.com/ ....' What am I doing wrong. All I want to do is copy one file to multiple folders which are all level one sub-folders of a parent folder we know the path to. By the way ln -s gives exactly the same error Thanks in advance |
The problem is that when the wildcard is expanded the command line looks like
Code:
cp ./.qmail /var/qmail/mailnames/user1/.qmail /var/qmail/mailnames/user2/.qmail /var/qmail/mailnames/user2/.qmail Code:
# for dest in /var/qmail/mailnames/* Code:
# for dest in $(find /var/qmail/mailnames -mindepth 1 -type d) |
Excellent, thanks for the quick response. Works a treat. See what you mean about refining. Nearly orverwrote my quota files.
Thanks again, this is the best tip I've had for ages. I badly need to develop my bash scripting skills, do you know of any resources? Quote:
|
Is there a way to get this to work with directories that have spaces in their names? This is a great solution otherwise. Whenever I try this, it copies my file into directories with no spaces just fine, but if the directory has a space in the name, i end up with a file named the first part of the directory name in the directory above it.
Quote:
|
iirc, you need to change the Internal Field Separator (IFS) shell var. By default it's space or tab or newline, and you want to reduce it to just a newline inside the shell script.
At the top put IFS=" " That's a newline (rtn) with surrounding quotes. This new definition will revert to normal when the shell prog exits. Here's a good tutorial: http://rute.2038bug.com/index.html.gz , also http://www.tldp.org/LDP/abs/html/ & http://tldp.org/LDP/Bash-Beginners-G...tml/index.html |
does this help?
1) link to Advanced Bash Scripting Guide: http://tldp.org/LDP/abs/html/ 2) [lcole@harley ~]$ find ~/"space in name" -mindepth 1 -type d /home/lcole/space in name/a /home/lcole/space in name/b /home/lcole/space in name/a b |
thank you for the fast responses :) some new things to try, i'll keep you posted.
|
just to update, setting IFS worked great, thanks :)
Quote:
|
All times are GMT -5. The time now is 11:24 PM. |