您的位置:首页 > 运维架构 > Shell

编写shell脚本处理test文件

2013-12-06 13:49 204 查看
编写shell脚本处理test文件,如下内容
http://bba.autlo.com/
http://Ucar.autlo.com/
http://Beijing.autlo.com/
得到结果:
http://bba.autlo.com/index.html
http://Ucar.autlo.com/index.html
http://Beijing.autlo.com/index.html

方法一:
awk -F "/" '{OFS="/"}{ $0~/^http:/;$4="index.html";print $0 }' test
方法二:
sed 's/autlo.com\/$/autlo.com\/index.html/' test
方法三:
sed 's/\(.*\)/\1index.html/' test
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息