Created
June 16, 2025 15:51
-
-
Save ashishjullia/50dccec669fdf086d6b544713bb439fa to your computer and use it in GitHub Desktop.
convert cert or key to single line with \n included
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
awk '{sub(/\r$/,""); printf "%s\\n", $0}' filename | |
This command reads a file line by line and converts it into a single, long string, using the literal characters \n as a separator. | |
It does two main things for every line it reads: | |
It Cleans: The sub(/\r$/,"") part finds and removes the invisible Windows "carriage return" character (\r) from the end of the line. If a line is already clean, this part does nothing. | |
It Joins: The printf "%s\\n", $0 part prints the cleaned line, followed immediately by the text \n. Because printf doesn't add a line break, all the lines get joined together into one. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment