Score:0

AWK Command to add new line ending to send Encrypted Private Key via API

gq flag

How to add new line ending \n to Encrypted private key which has a blank line.

Example Encrypted Private:

-----BEGIN RSA PRIVATE KEY-----
Proc-Type: 4,ENCRYPTED
DEK-Info: AES-128-CBC,35D7ADF9A8CD58CE3B0D881497052104
    
PpHyOhF/iUhzf5Pp62UIVAeMCYsdluWBj4OXpIA7iO/xwA7Gq2rmSclNIPwz3gdC
g9oxQciIWdQEJt1Gq51ff2Mxflf0vFqlzO8PRnctz5gXKWhkG28FMcSt6wJ0kwai
Upv2rwZroX8D5aDOC3vXVZf4U7iAG0WZVCf4XoNgLcxN+FK0xGuw55/PQHnePWw2
S5V4IJmvsxJH3mjwbkDsVxIkkXVCkgJEeb6THqbhxjVdQVPcTp4rn937RJXwIhS8
M2TU5o5TQj9Ny0wngjFH7ux0FfT+6LT9nkEBvwm7hU7AMYM+SGTWOfrCc5rzMS5O
4Fy89JVzT1sUgSWHvWQTQjnBzIIh0KSF7kZQ7vlM5EWreLRj1Irho7+2UCYmvaLe
X2F39tSy6kbvofuAHzn4aqj+dxop+JD8+9L47vrVHRI+op6QT/HuowCcdsEAkuh+
MmvhN06g/sg+9j8SsGnQFfH0KZddiPr1n3riRF+Yds8PpT69QDxCcBJl2OIz7J9c
4DX+zq2KeG6jcERAj9xbVFL6CajE4w4mpVXZEWX35fF6/2rV/ZwDTdYi87qT3jnP
6kvcvwMqcOwB7QIHbMvCUyCRZkhkj6qoTBIMJMU2XRrWFzzLjUq4c7XxR1cs9lSB
cim2Ylv+b25hHNEasv04BCDkRqnjBcJXVnXZU5VX8JQYjiYtXaMa6EgwG5xhJPrn
VpZnrWAVgrz8t+SPr61WmEtZbQO8295bEpBxXin8bbD5YebQQP901DnammgeBiAK
618WSmSqO5V6Cwq8EJioh+6GjuMEevojo2voDd98M7Ua+8yFKda5THTnU3+jjMc7
d0fmVRtrLfxV8lkVjLDiRYkwErW+bcKeAWSXD5DGAbUeMZ9Fzmrj/kTl9zqXNznD
EwlZ6HqT/69Dk5RfgOrJYOdSGkdmnKoL4OhpKmkigRth9coBcCfvZcehR/QfdMfJ
/PP7uuZAGSm2q91hrMg7ukTpXLH+MfNPBya73HgZlE0NfINEfp/Ba5eu9/2GHSK0
aXMZUG3tsHYR0P82nI+2WFAmWFurinHLEaoTya14HvZPIs0TtDh8yzu+hRl0nkHf
ahwG72crxC7+aWH5/GgYBg+83xBSoBArRM1lThyQGHS4wTKQAgVffDtuVb1czLTw
tB88RfDsASYrCt8aGqBmIjwKocgjNF+vD5RSF5obTI9na/l7Li9Hvp7YcxARY8vi
ORUAEBosj5jr930Rwg7dSKGAZ49lYYJQ/MKSYECSJ8bUsUL+rwubIHuwVwi7aMun
Yu2NA6+viTJX9/FrhNmYA1SB2Fv+IfzHOK3zFTuf48usdOYpNRa6rzX8NC9EPtn+
gEAAJFV/XtmfwNKfPNPOYcx/xGX2twkCJ4QN1p0kQP/GkB6jqHUV+X5Upffr5Zhw
6Xk7mEi25EphyYbP5D+SBJ98+5qr5L1Wu6QImSby3nkPzZtGpUsG5qb2lIxpmseW
Q0f2+1s+Netw0JRgMOYoUilLDv6/Nu5e9++LovoJq8xTCIhZSDv0VpDuZtw3LC7w
+vzNeG1l2u/Xy2zqME7dedXgNLNd3TiXJvKEs+zWQ3GiW3IrxMcawNFfvTEy2Dze
-----END RSA PRIVATE KEY-----

I tried the below command, but it does not consider the blank line :

awk 'NF {sub(/\r/, ""); printf "%s\\n",$0;}'

Below is the output:

-----BEGIN RSA PRIVATE KEY-----\nProc-Type: 4,ENCRYPTED\nDEK-Info: AES-128-CBC,35D7ADF9A8CD58CE3B0D881497052104\nPpHyOhF/iUhzf5Pp62UIVAeMCYsdluWBj4OXpIA7iO/xwA7Gq2rmSclNIPwz3gdC\ng9oxQciIWdQEJt1Gq51ff2Mxflf0vFqlzO8PRnctz5gXKWhkG28FMcSt6wJ0kwai\nUpv2rwZroX8D5aDOC3vXVZf4U7iAG0WZVCf4XoNgLcxN+FK0xGuw55/PQHneP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49lYYJQ/MKSYECSJ8bUsUL+rwubIHuwVwi7aMun\nYu2NA6+viTJX9/FrhNmYA1SB2Fv+IfzHOK3zFTuf48usdOYpNRa6rzX8NC9EPtn+\ngEAAJFV/XtmfwNKfPNPOYcx/xGX2twkCJ4QN1p0kQP/GkB6jqHUV+X5Upffr5Zhw\n6Xk7mEi25EphyYbP5D+SBJ98+5qr5L1Wu6QImSby3nkPzZtGpUsG5qb2lIxpmseW\nQ0f2+1s+Netw0JRgMOYoUilLDv6/Nu5e9++LovoJq8xTCIhZSDv0VpDuZtw3LC7w\n+vzNeG1l2u/Xy2zqME7dedXgNLNd3TiXJvKEs+zWQ3GiW3IrxMcawNFfvTEy2Dze\n-----END RSA PRIVATE KEY-----

But the expected result should have \n\n reflecting a blank line after DEK-Info: AES-128-CBC,35D7ADF9A8CD58CE3B0D881497052104:

-----BEGIN RSA PRIVATE KEY-----\nProc-Type: 4,ENCRYPTED\nDEK-Info: AES-128-CBC,35D7ADF9A8CD58CE3B0D881497052104\n\nPpHyOhF/iU....
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.