How to search for a newline that is not preceeded by } and remove it
0
votes
2
answers
92
views
I want to use
sed
to search for line breaks that are not preceded by }
.
The regex for identifying theses cases is: [^}]$
. What I want to say: If the line ended without }
then remove the new line. Any line should end with }
before the newline.
How to put that in sed
to remove them?
**EDIT:**
Example:
{'Date': 'Fri, 19 Apr 2019 07:23:14 GMT', 'Server': 'Apache', 'Vary': 'Qualys-Scan', 'Strict-Transport-Security': 'max-age=31536000;includeSubDomains;preload', 'Set-Cookie': 'ASP.NET_SessionId=ivoa5bhet0s2ygkylmimvkie; path=/; secure; HttpOnly;SameSite=strict, SC_ANALYTICS_GLOBAL_COOKIE=12f133ea; expires=Thu, 19-Apr-2029 07:23:14 GMT; path=/; secure; HttpOnly;SameSite=strict, SC_ANALYTICS_SESSION_COOKIE=336B5|1|ivoa5; path=/; secure; HttpOnly;SameSite=strict, incap_ses_885_270026=cDp/VlO1AHgshF9F6SZID==; path=/; Domain=.zurich.co.uk, ___utmvm=dlNaoEsuXSO; path=/; Max-Age=900, ___utmvay=nWJx01KvGT; path=/; Max-Age=900, ___utm=JZy
XEtOwalQ: PtR; path=/; Max-Age=900', 'X-Content-Type-Options': 'nosniff', 'X-XSS-Protection': '1; mode=block', 'Cache-Control': 'private', 'Content-Type': 'text/html; charset=utf-8', 'Keep-Alive': 'timeout=5, max=10', 'Connection': 'Keep-Alive', 'X-Iinfo': '8-3925806-3807 NNNN CT(73 151 0) RT(155583 5) q(0 0 3 0) r(6 6) U5', 'X-CDN': 'Incapsula', 'Content-Encoding': 'gzip', 'Transfer-Encoding': 'chunked'}
When I applied your script, it combined the lines. However, the new line starts with tab
. How to also remove the spaces if the newline starts with spaces?
Asked by None
(219 rep)
May 11, 2019, 12:51 PM
Last activity: Dec 29, 2024, 09:45 AM
Last activity: Dec 29, 2024, 09:45 AM