编写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