Use the following script adapted from zimbra wiki:
#!/bin/bash
# customize these to your needs:
domain="zimbra.example.com"
# get cos_id with command zmprov gc <COSname>, eg. zmprov gc default | grep zimbraId
cos_id="e00428a1-0c00-11d9-836a-000d93afea2a"
shadow="shadow.text"
script="import-shadow.sh"
x=0
echo '' > $script
for entry in `cat $shadow`
do
user=`echo $entry|cut -f1 -d":"`
pass=`echo $entry|cut -f2 -d":"`
if [ "x$pass" != "x*" ]
then
if [ "x$pass" != "x$!" -a "x$pass" != "x$!!" ]
then
echo "zmprov ca $user@$domain temppasswordQAZXSW displayName $user zimbraCOSid $cos_id" >> $script
echo "zmprov ma $user@$domain userPassword '{crypt}$pass'" >> $script
x=$[x+1]
fi
fi
done
echo
echo
echo "$x accounts exported to \"$PWD/$script\""
echo ''
echo "Run $script to do the import."