I am new to shell scripting and working on script. In which I need to create a html report and attach this html report content in json request filed.Then we are using that request to call an API.
I have Json request as Template in the template have a place holder called CONTENT in which I have to replace generated HTML content after encode it using base64.
When I try to add the encoded string in my template using both AWK and sed im getting Argument list is too long error. As my generated HTML file is having 40K lines.
With below approaches I am getting same error.
encStr="$(cat ./myreport.html | base64)"
#AWK-Approach
awk -v var="$encStr" '{gsub("CONTENT", var, $0); print}' /path/totemplate > output.tmp
#SED-Approach
sed -i "s|CONTENT|$encStr|" output.tmp
There is a suggestion to change sed to ed and put the commands in separate file. As per https://unix.stackexchange.com/a/284188/149867 but when I create a seprate .sh file and include it in my current script its not working. Any detailed example for this approach or any other approach.
r
command ofsed
(using the place holder pattern as address)