Sed - An Introduction and Tutorial by Bruce Barnett
|
With no flags,the first matched substitution is changed. With the "g" option,all matches are changed. If you want to modify a particular pattern that is not the first one on the line,you could use "(" and ")" to mark each pattern,and use "1" to put the first pattern back unchanged. This next example keeps the first word on the line but deletes the second: sed 's/([a-zA-Z]*) ([a-zA-Z]*) /1 /' Yuck. There is an easier way to do this. You can add a number after the substitution command to indicate you only want to match that particular pattern. Example: sed 's/[a-zA-Z]* //2' (编辑:网站开发网_马鞍山站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |

