【Linux shell】sed实践(2)

    xiaoxiao2022-07-16  126

    1、匹配单引号的行并删除 #sed -i "/'/d" test.file 匹配用双引号 2、匹配以单引号开头的行并删除 #sed -i "/^'/d" test.file 用^符号 3、多点编辑-e #sed -e "/'/d" -e "s/lgsb/lgsb ' '/g" test.file 匹配单引号的行删除并匹配有lgsb的行替换为lgsb ' ' -e:多点编辑 4、匹配tab或空格开头的行并删除 #sed -i "/^[ \t]/d" test.file [ \t]:表示tab或空格 5、匹配tab或空格开头同时满足含有单引号的行并删除 #sed -i "/^[ \t]/{/'/d}" test.file 6、匹配lgsb或者dwsb的行并打印 #sed -n '/lgsb\|dwsb/p' test.file  或者 #sed -n '/\(lgsb\|dwsb\)/p' test.file 7、在最后一行结尾添加单引号 #sed -i "s/$/'/d" test.file 相关资源:新版Linux Shell编程实训(全)20170518.docx
    最新回复(0)