echo换行输出需要转义符 -e 看以下例子: echo -e "It is the first line." >> a; echo -e "It is the second line.\c" >> a; echo -e "It is the third line." >> a; echo -e "\nIt is the forth line." >> a 输出: It is t
假设 str="a,b,c,d" echo ${str} | sed "s/,/\n/g" 输出: a b c d echo ${str} | sed "s/,/\n/g" | sed "s/\n/,/g" 输出: a b c d 没有匹配到\n换行符 这是因为sed 模式是以\n换行符作为行的结束标记的.它没有办法匹配到\n再替换 解决方法: echo ${str} | sed "s/,/\n/g" |
我整理了几个比较适合的实例了,对于它们我们是有很多站长都测试过并用过了,不过文章最后我的总结也是生重要的哦,至于原因我也说不上了,因为chr是ascii编码了所以有时浏览器会自动转成ascii,特别像ff浏览器就是这样的. 一,下例可以去除额外空白 代码如下 复制代码 <?php $str = " This line containstliberal rn use of whitespace.nn"; // First remove the leading/trailing