开发者

Replacing output text of a command with a string in a Shell Script

Hello and thank you for any help you can provide

I have my Apache2 web server set up so that when I go to a specific link, it will run and display the output of a shell script stored on my server. I need to output the results of an SVN command (svn log). If I simply put the command 'svn log -q' (-q for quiet), I get the output of:

Replacing output text of a command with a string in a Shell Script

(of course not blurred), and with exactly 72 dashes in between each line. I need to be able to take these dashes, and turn them into an html line break, like so:

Replacing output text of a command with a string in a Shell Script

Basically I need the shell script to take the output of the 'svn log -q' command, search and replace every chunk of 72 dashes with an html line break, and then echo the output.

Is this at all possible? I'm somewhat a noob at shell scripting, so please开发者_Python百科 excuse any mess-ups.

Thank you so much for your help.


 svn log -q | sed -e 's,-{72},<br/>,'


If you want to write it in the script this might help:

${string//substring/replacement}
Replace all matches of $substring with $replacement.

stringZ=abcABC123ABCabc

echo ${stringZ/abc/xyz}       # xyzABC123ABCabc
                              # Replaces first match of 'abc' with 'xyz'.

echo ${stringZ//abc/xyz}      # xyzABC123ABCxyz
                              # Replaces all matches of 'abc' with # 'xyz'.
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜