Empty Zimbra ML and populate it from file

or populate from file

 

 

Step 1

do a backup of the mailing list

 

zmprov gdlm NAME OF THE ML | tail -n +4 > /PATH/OF/THE/BACKUPFILE/FILENAME.txt

 

Step 2

Extract ML members and remove them

 

for a in `zmprov gdlm NAME OF THE ML | tail -n +4` ; do
   zmprov rdlm NAME OF THE ML $a
done

 

Step 3

Import new members (or add members) from a previously prepared text file, this version is a bash executable file named add-to-ml.sh with this content

for i in $(cat ${1}); do
   zmprov adlm NAME OF THE ML $i
done

 

The usage is this

 ./add-to-ml.sh /PATH/OF/THE/NEW_MEMBERS_FILE/FILENAME.txt

(the .txt extension is not mandatory but the file must be executable for the owner, chmod +x)

 For tips on how to clean a list of email addresses see my previous post:

http://www.apastore.org/index.php?Rimuovere-righe-a-capo-accapo-e-righe-vuote

(in italian)