2016-11-30 154 views
1

EC2のシェルスクリプトを使用してAWS SNS通知を送信します。次は私のコマンドです:シェルスクリプト内の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パラメータに改行を追加するにはどうすればよいですか? printfを使用して

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

:バッシュ/は、ksh93/Zshのでリテラルの改行文字

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

を挿入

答えて

3

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

おかげでたくさんルスラン...解決策は有用でした問題が解決した – Akki

関連する問題