我的目标是调用以下命令:
(echo "test";uuencode testfile1.txt testfile1.txt;uuencode testfile2.txt testfile2.txt)|mail -s "subject" "recipient@domain.com"在shell中调用它就像预期的那样工作。
但是,当uuencode命令存储在数组中时,我想这样做:
ARR=("uuencode testfile1.txt testfile1.txt" "uuencode testfile2.txt testfile2.txt")我试过以下几种方法:
STR=$(IFS=';'; echo "${ARR[*]}");
(echo "test";"$STR")|mail -s "subject" "recipient@domain.com"但我不断地得到以下错误:
uuencode testfile1.txt testfile1.txt;uuencode testfile2.txt testfile2.txt: command not found怎么解决这个问题?
我想它不承认;是命令分隔符。
发布于 2016-10-19 15:18:28
看起来,您要将每个命令作为字符串存储在数组中,并将它们连接到一个更大的字符串中。您可以在字符串上执行一个eval。
(echo "test";eval "$STR")|mail -s "subject" "recipient@domain.com"https://stackoverflow.com/questions/40135115
复制相似问题