I've got the following code, which is supposed to take filenames as arguments, and send them to my email address, which is derived from a username:
#Email Script from linux
#Define username e.g. pp_roman
u="$USER"
#Remove the pp_ and store to variable e.g. roman
u2=${u#"pp_"}
#Define Email portion
em="@workemail.com"
#Combine the username e.g. [email protected]
u3=$u2$em
#Arguments for script
for FILE1 in "$@"
do
filename="-a $FILE1"
done
##This returns the full string with $filename variables for arguments, and email from $u3
mailx $filename -s "Subject" $u3 < /dev/null
However when passing multiple arguments, only the last mentioned filename is sent as an attachment. How do I pass multiple arguments into the $filename variable all appended by "-a"?
bash,ksh,zsh,dash? Or does this need to conform to the POSIX specification for portability?