Solved

sed - replace backslash linefeed with backslash

Posted on 2011-02-11
6
896 Views
Last Modified: 2012-05-11
sed 's/\\\n/\\/g' doesn't work. What should it be?
0
Comment
Question by:modsiw
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 40

Expert Comment

by:omarfarid
ID: 34873420
what do you get when you run command?

try

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

Author Comment

by:modsiw
ID: 34874076
My command doesn't modify the file at all.

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

Author Comment

by:modsiw
ID: 34874095
sed 's/\n//g'

doesn't do anything either. I'd expect it to turn the file into a single long line
0
More Than Just A Video Library

Train for your certification. Learn the latest DevOps tools. Grow your skillset to do better work.

At Linux Academy, we release new training modules every week so you'll always be up to date on the latest tech.

 
LVL 48

Expert Comment

by:Tintin
ID: 34874247
I'd use tr instead

tr -d '\n' <file

Open in new window

0
 
LVL 23

Expert Comment

by:Maciej S
ID: 34878766

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

Open in new window

0
 
LVL 23

Accepted Solution

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

Open in new window

0

Featured Post

Why Off-Site Backups Are The Only Way To Go

You are probably backing up your data—but how and where? Ransomware is on the rise and there are variants that specifically target backups. Read on to discover why off-site is the way to go.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Using 'screen' for session sharing, The Simple Edition Step 1: user starts session with command: screen Step 2: other user (logged in with same user account) connects with command: screen -x Done. Both users are connected to the same CLI sessio…
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 how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

717 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