Shell Newline
Solved
bibitun
Posted messages
10
Status
Membre
-
bibitun Posted messages 10 Status Membre -
bibitun Posted messages 10 Status Membre -
Hello,
I have a problem that I've been trying to solve since Friday without success. In fact, I'm writing a shell script, where I need to insert a line using sed, followed by a newline and then another line:
sed s/line_to_replace/line1\nline2/g file > file;
The problem is that the newline is not recognized, and I just get line1nline2.
I doubled the double slash, and I get the same thing; when I triple it, I get line1\nline2.
I should mention that I'm using Putty to connect to the server; unfortunately, I have no choice of tool.
Thank you for your help.
I have a problem that I've been trying to solve since Friday without success. In fact, I'm writing a shell script, where I need to insert a line using sed, followed by a newline and then another line:
sed s/line_to_replace/line1\nline2/g file > file;
The problem is that the newline is not recognized, and I just get line1nline2.
I doubled the double slash, and I get the same thing; when I triple it, I get line1\nline2.
I should mention that I'm using Putty to connect to the server; unfortunately, I have no choice of tool.
Thank you for your help.
6 réponses
Hello,
What operating system are you using on your server?
What version of "sed"?
Try with the ASCII code:
It's a ZERO and not a capital O...
--
Zen my nuggets ;-)
Do something for the environment, close your windows and adopt a penguin.
What operating system are you using on your server?
What version of "sed"?
Try with the ASCII code:
sed 's/lign_remplacer/ligne1\x0Aligne2/g' fichier > fichier
It's a ZERO and not a capital O...
--
Zen my nuggets ;-)
Do something for the environment, close your windows and adopt a penguin.