• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 916
  • Last Modified:

sed - replace backslash linefeed with backslash

sed 's/\\\n/\\/g' doesn't work. What should it be?
0
modsiw
Asked:
modsiw
1 Solution
 
omarfaridCommented:
what do you get when you run command?

try

sed 's/\\n/\/g'
0
 
modsiwAuthor Commented:
My command doesn't modify the file at all.

Yours doesn't work; blackslash must be escaped.
0
 
modsiwAuthor Commented:
sed 's/\n//g'

doesn't do anything either. I'd expect it to turn the file into a single long line
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
TintinCommented:
I'd use tr instead

tr -d '\n' <file

Open in new window

0
 
Maciej SsysadminCommented:

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

Open in new window

0
 
Maciej SsysadminCommented:
Hmm.. a little bit shorter (and simpler) one:
sed ':L;N;s/\n/\\/;tL'

Open in new window

0

Featured Post

[Webinar] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now