ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
May we know the value of ${content[$n]} and what an "escape breakline" is? When you ask "How to remove escape breaklines to \n?" do you mean "How to change escape breaklines to \n?"
May we know the value of ${content[$n]} and what an "escape breakline" is? When you ask "How to remove escape breaklines to \n?" do you mean "How to change escape breaklines to \n?"
Sorry I wanted to write to escape breaklines.
text
Code:
title Sata Mandriva kernel
(hd0,2)/boot/vmlinuz BOOT_IMAGE=linux root=(hd0,2) resume=UUID=e12487ff-6d6f-44c4-9e03-33f545b3b798 splash=silent vga=788
initrd (hd0,2)/boot/initrd.img
Well breakline is the invisible \n . (edit - proper: new line!)
End escape the invisible breakline (or break line?) means to transform invisible \n to visible: \n:
Target string should look like this:
'title Sata Mandriva\nkernel (hd0,2) ...\n...'
My command cannot work. Cannot change the character because there is not breakline \n . It was removed because of the file separator.
title Sata Mandriva kernel\n(hd0,2)/boot/vmlinuz BOOT_IMAGE=linux root=(hd0,2) resume=UUID=e12487ff-6d6f-44c4-9e03-33f545b3b798 splash=silent vga=788\ninitrd (hd0,2)/boot/initrd.img\n
I would try #3 but I need to escape the characters. In #3 they are not escaped.
Code:
#1 - 1st I need to escape some characters but it removes the \n
original_block=$(echo ${original_content[$n]} | awk 'BEGIN { FS="\n"; RS="";} {b = gensub(/([\]*+/])/, "\\\\&", "g"); print b }')
#2 - not working
original_block=$(echo "$original_block" | awk '{printf "%s\\n",$0}');
#3 - working
original_block=$(echo "${original_content[$n]}" | awk '{printf "%s\\n",$0}');
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.