Shell Newline
Solved
bibitun
Posted messages
10
Status
Member
-
bibitun Posted messages 10 Status Member -
bibitun Posted messages 10 Status Member -
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 answers
-
Hello,
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. -
Always the same problem: it shows me ...line1x0Aline2...
How can I know the version of the server and the sed command please?
Thank you -
The command you gave me didn't work, I tried the oslevel command, it returned: 5.2.0.0.
uname -a returned: AIX xxxxx 2 5 .....
For sed, the command didn't work. -
Could you please explain this entry story to me more?
Thank you. -
-
It worked, but by adding another backslash: \\
Thank you very much for this help, you saved my day! :-)