text2html
来自「《j2ee经典实例详解》的源代码。原书无附带光盘。介绍的是一个在线银行系统的例子」· 代码 · 共 34 行
TXT
34 行
#!/bin/csh# text2html# Convert a (text) file to preformatted html & put results on std outif ("$1" == "" || "$2" != "") then echo "usage: $0 <file> | " echo " converts <file> to preformatted xml" exitendif# PROBLEM: "&" characters in the file, as well as "<" characters.# SOLUTION:# 1. convert < to < # 2. convert & to &# 3. convert &lt; back to <## NOTE:# "&" in the substitution pattern stands for the search pattern# It is therefore necessary to escape the & as \& to get the &-character# inserted into the substitution-string.# Work around a shell script bug# --When the text doesn't end in a NL, the last# --line does not get through sedecho "" >> $1echo "<html>" echo "<body><pre>" #cat $1 | sed "s^<^\<^g" | sed "s^&^\&^g" | sed "s^&lt;^\<^g"cat $1 | sed "s^&^\&^g" | sed "s^<^\<^g"echo "</pre></body>"echo "</html>"
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?