2016-11-30 1 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 매개 변수에 개행을 추가하려면 어떻게해야합니까? 배쉬/ksh93의/zsh을에서 리터럴 개행 문자

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

삽입

답변

3

가 :

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

하는 printf 사용 :

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

고마워 루슬란을 ... 해결책은 도움이되었다 문제가 해결되었습니다. – Akki