在Shell脚本中向AWS SNS消息添加换行符

Akki:

我想通过EC2中的Shell脚本发送AWS SNS通知。以下是我的命令:

aws sns publish --topic-arn arn:aws:sns:x:x:x \
  --region=$AWS_DEFAULT_REGION \
  --subject "Processing Error - ${tablename}" \
  --message "An error has occurred in API data processing. The error file ${error_file} has been written to the errors folder...The file contents of ${error_file} are : $(cat ${error_file})"

我的问题是,在使用“ cat”命令打印文件内容之前,我不知道如何插入换行符我想在换行符后打印文件的内容。现在将其附加到"The file contents of ..."

如何在--message参数中添加换行符

罗斯兰·奥斯曼诺夫(Ruslan Osmanov):

插入文字换行符

aws sns publish --message="...
$(cat ${error_file})" # other options

在Bash / Ksh93 / Zsh中:

aws sns publish --message="..."$'\n'"$(cat ${error_file})" \
  # other options

使用printf

aws sns publish --message="$(printf "%s\n%s" "..." "$(cat ${error_file})")" \
  # other options

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章