六狼论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博账号登陆

只需一步,快速开始

搜索
查看: 39|回复: 0

linux shell sed practise

[复制链接]

升级  1.6%

154

主题

154

主题

154

主题

进士

Rank: 4

积分
508
 楼主| 发表于 2013-1-26 12:42:28 | 显示全部楼层 |阅读模式
use sed to implement change some text from the specify file, like as
 
 
#! /bin/Bashsetting_file=/cydrive/c/dev/maven/setting.xml.txtpattern="<db.user>*<\/db.user>"target="<db.user>_35<\/db.user>"sed -n -i -e 1,6s/$pattern/$target "$setting_file"  
 
 
 
 
modify the properties file by the such way:
 
 
tmp_file=/tmp/tmpfile.$$schema=$1user="owner_"$schemapassword="owner_"$schema"_XXXXX"cp local.properties $tmp_filesed -i -e s/app.local.usr=.*/app.local.usr=$user/ "$tmp_file"sed -i -e s/app.local.password=.*/app.local.password=$password/ "$tmp_file"mv $tmp_file local.properties  
 
您需要登录后才可以回帖 登录 | 立即注册 新浪微博账号登陆

本版积分规则

快速回复 返回顶部 返回列表