“Linux 基础入门”实验报告

正则表达式基础

图片描述 关键步骤:查找 /etc/group 文件中以 shiyanlou 为开头的行: grep 'shiyanlou' /etc/group; grep '^shiyanlou' /etc/group; ②4.2:sed -i 's/sad/happy/g' test : g 表示全局范围 sed -i 's/sad/happy/4' test : 4 表示指定行中的第四个匹配字符串; ③图片描述 关键步骤:奇数行的表示:1-2p ④关键步骤:将输入文本中"shiyanlou" 全局替换为"hehe",并只打印替换的那一行,注意这里不能省略最后的"p"命令: sed -n 's/shiyanlou/hehe/gp' passwd;

最新评论
暂无评论~