日期:2014-05-16 浏览次数:20764 次
?
echo .abc |grep "^\." ;echo $?
?
?
?
echo /abc |grep "^/" ;echo $?
?
?
echo "\abc"? |grep "^\\\\" ;echo $?
?
?
两种方式:可以使用-e ,也可以使用分号。
范例01:
sed 's/abc/000/g;s/000/uuu/g' abc.txt |
?
范例02:
[whuang@localhost test]$ echo The tiger cubs will meet on Tuesday after school | sed 's/tiger/wolf/; s/after/before/' The wolf cubs will meet on Tuesday before school |
?
?
?
以下是错误的:
find $kingbase_own_home/.local/share/applications -type f -name "*.desktop" |xargs -i sed -i "s#^\(Icon=\)\([^ ]\+\)$#\1${install_dir}\2.png#g" {}
正确的应该是:
find $kingbase_own_home/.local/share/applications -type f -name "*.desktop" |xargs -i sed -i "s#^\(Icon=\)\([^ ]\+\)\$#\1${install_dir}\2.png#g" {}
点评:linux 会把$# 解析成为0.
?
范例01:
脚本名称:sed_#.sh
脚本内容:
#!/bin/sh echo Icon=KDB_ISQL|sed "s#^\(Icon=\)\(KDB_ISQL\)$#\1CCC\2.png#g" |
脚本运行结果:
[root@localhost sed_study]# sh sed_#.sh sed:-e |