Solved

sed - replace backslash linefeed with backslash

Posted on 2011-02-11
6
831 Views
Last Modified: 2012-05-11
sed 's/\\\n/\\/g' doesn't work. What should it be?
0
Comment
Question by:modsiw
6 Comments
 
LVL 40

Expert Comment

by:omarfarid
Comment Utility
what do you get when you run command?

try

sed 's/\\n/\/g'
0
 
LVL 3

Author Comment

by:modsiw
Comment Utility
My command doesn't modify the file at all.

Yours doesn't work; blackslash must be escaped.
0
 
LVL 3

Author Comment

by:modsiw
Comment Utility
sed 's/\n//g'

doesn't do anything either. I'd expect it to turn the file into a single long line
0
Get up to 2TB FREE CLOUD per backup license!

An exclusive Black Friday offer just for Expert Exchange audience! Buy any of our top-rated backup solutions & get up to 2TB free cloud per system! Perform local & cloud backup in the same step, and restore instantly—anytime, anywhere. Grab this deal now before it disappears!

 
LVL 48

Expert Comment

by:Tintin
Comment Utility
I'd use tr instead

tr -d '\n' <file

Open in new window

0
 
LVL 23

Expert Comment

by:Maciej S
Comment Utility

sed ':L;$!N;s/\n/\\/g;tL'

Open in new window

0
 
LVL 23

Accepted Solution

by:
Maciej S earned 500 total points
Comment Utility
Hmm.. a little bit shorter (and simpler) one:
sed ':L;N;s/\n/\\/;tL'

Open in new window

0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

If you have a server on collocation with the super-fast CPU, that doesn't mean that you get it running at full power. Here is a preamble. When doing inventory of Linux servers, that I'm administering, I've found that some of them are running on l…
Introduction We as admins face situation where we need to redirect websites to another. This may be required as a part of an upgrade keeping the old URL but website should be served from new URL. This document would brief you on different ways ca…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now