Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

sed - replace backslash linefeed with backslash

Posted on 2011-02-11
6
Medium Priority
?
910 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
Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

 
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 2000 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

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Question has a verified solution.

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

How many times have you wanted to quickly do the same thing to a list but found yourself typing it again and again? I first figured out a small time saver with the up arrow to recall the last command but that can only get you so far if you have a bi…
Join Greg Farro and Ethan Banks from Packet Pushers (http://packetpushers.net/podcast/podcasts/pq-show-93-smart-network-monitoring-paessler-sponsored/) and Greg Ross from Paessler (https://www.paessler.com/prtg) for a discussion about smart network …
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.
Suggested Courses

650 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