编写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
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
相关文章推荐
- 编写个shell脚本将/home/test 目录下大于10K的文件转移到/tmp目录下
- shell 脚本编写一个用户名,密码,编号的test.txt文件供数据库测试使用
- shell脚本处理文件
- Linux下shell脚本编写:创建文件
- 用shell脚本编写区别两个文件夹内文件的不同
- shell脚本,每次读取文件的一行,逐行读取并处理
- shell 脚本读写处理文件
- 编写个shell脚本将当前目录下大于10K的文件转移到/tmp目录下
- shell脚本循环处理文件数据
- 编写shell脚本unload表格里的内容到指定文件里
- jmeter压测脚本编写与静态文件处理
- Linux编写shell文件之后的权限处理
- shell操作练习(编写shell脚本完成统计文件中的每个月份设备的出现次数)
- linux下使用shell编写的删除历史文件的脚本 find | xargs tar 有文件个数限制哦
- window下编写shell脚本出现格式错误的处理方法
- Linux查看磁盘信息(编写shell脚本来分析文件的占用情况)
- linux 用notepad++编写shell脚本出现/bin/sh^M: bad interpreter: 没有那个文件或目录l的解决方案
- 编写一个SHELL脚本,可以获得指定目录下的所有文件及文件夹的大小。输出的样式与 ls -lh 命令相同。
- shell脚本对文件的处理
- 编写一个shell命令脚本来交叉编译.c文件,代替Makefile