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ODA4MC9lamJjYS9wdWJsaWN3ZWIvd2ViZGlzdC9jZXJ0ZGlz\ndD9jbWQ9Y3JsJmlzc3Vlcj1DTj1CcmFuZCUyMFByb3RlY3Rpb24lMjBFQ0MlMjBQ\naWxvdCUyMENBJTIwMSxPPVdJU2VLZXklMjBTQSxDPUNIMA4GA1UdDwEB/wQEAwIB\nujAyBgNVHSUEKzApBggrBgEFBQcDAQYIKwYBBQUHAwIGCCsGAQUFBwMEBgkqhkiG\n9y8BAQUwDQYJKoZIhvcNAQELBQADggEBADyPydabP2qf3U4uJ8WpFtGhT12X66q+\nA0mMZ1ii7zQeZ70wrCCEf0anxAxuXNwI8lgGggmvmhjmxZdQEy5FR/0JXij3RZxF\n4l37HKDlRQOvzYbitJjmn3U9hFG1Xl9psbWT69IklVAn0Be7kOIPb2WEUn3y2/tv\nI8yHbjBdKHQDE2jG1EfuEr2Vu8u2jHr/4s6CT94T1Y1CbJaQv0Maj9gGLSP3S+8w\nAqfA92HUlDUeVEZ0TTesjuieNGiIi87AtOh2qLGoExDBIvkNoYLZeV1wXXUvOX8j\nn/DC13lNczY/Ugsv7BMX7HfQuXrxinvZcrILX10yJ1e43/lrLRZULI4=\n-----END CERTIFICATE-----\n
如何在bash脚本中将这些“\ n”替换为真正的换行符?
答案 0 :(得分:1)
您可以使用sed
:
cat cert | sed -e 's/\\n/\n/g'