Reputation: 77
I want to get an output in this format:
# JENKIKNS start ===
<p>abc</p>
<p>def</p>
<p>ghi</p>
# JENKINS end ===
but I get this:
# JENKIKNS start ===
abc def ghi
# JENKINS end ===
My code is here:
ABC="abc \
def \
ghi \
"
sed -i.orig "
/java/ i\
# JENKIKNS start === \\
"$ABC"\\
# JENKINS end === \\
" sampledeploy.sh
Upvotes: 0
Views: 45
Reputation: 4164
You mean something like that?
sampledeploy.sh | sed '/# JENKIKNS start ===/ {n;s/\(\w*\)/<p>\1<\/p>/g;s/ /\n/g}'
explanation
sed
'/# JENKIKNS start ===/ # search this pattern
{n # go to next line
; # next command
s/ # substitute
\(\w*\) # save words into arg1 (\1)
/<p>\1<\/p> # write \1 between tags
/g # on hole line
; # next command
s/ /\n/ # replace ' ' with '\n'
g}' # on hole line
Upvotes: 0
Reputation: 407
If you are looking at replacing \ with newline this should work
sed 's/\\/\\\n/g' test
Upvotes: 1