简体   繁体   中英

unix linux shellscript programming printing input arguments containing multiple words

I am trying to write a shell script for which 1st 2nd and 3rd...n argument contains multiple words

MAILING_LIST="abc@gmail.com xyz@gmail.com zed@gmail.com"
echo $MAILING_LIST
mailing "Error in Job"  " There were some records that couldn't be loaded into DB" " " $MAILING_LIST

Now i only want to print my mailing list in the function so that i can use that to send the email

obviously no of mails in mailing list can change and so forth .

Kindly help me with this issue.

PS if i use echo $# it gives me no of args as 6 now my requirement is to print/get the mailing list only in my function ..

Enclose the variable in quotes, since arguments are separated with spaces:

echo "$MAILING_LIST"
mailing "Error in Job"  " There were some records that couldn't be loaded into DB" " " "$MAILING_LIST"

Just like you did with "Error in Job" . If you had left those quotes out, there would have been eight arguments.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM