Solved

sed - replace backslash linefeed with backslash

Posted on 2011-02-11
6
863 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
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
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 
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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

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…
Little introduction about CP: CP is a command on linux that use to copy files and folder from one location to another location. Example usage of CP as follow: cp /myfoder /pathto/destination/folder/ cp abc.tar.gz /pathto/destination/folder/ab…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.

803 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