I have a script that currently does:
cat $body | uuencode $attachment $attachment | sendmail $sender -t
What should I adjust so that $attachment could be multiple attachments? I have come up with the below but it doesn't look correct?
cat $body |
for i in $attachments
do
uuencode $i $i
done
| sendmail $sender -t
Typically, you don't want to store a list of file names in a parameter. With default IFS
, spaces embedded within file names will give rise to problems. Instead, declare an array with files
a=(file1 file2 file3 file4)
(for file in "${a[@]}"; do uuencode "$file" "$(basename "$file")"; done) |
sendmail $sender -t