Locations of visitors to this page

Thursday, September 25, 2008

modify user profile in one-line shell script - 用shell脚本简单修改用户配置文件

---------- Forwarded message ----------
From: XIE WEN-MFK346 <wenxie at motorola.com>
Date: 2008/9/25
Subject: 如何使用unix命令修改配置文件
To: xiewenxiewen at gmail.com

比如说,有一个配置文件内容是这样的:


现在我想修改几个参数,ORACLE_HOME改成$ORACLE_BASE/product/9.2,ORACLE_SID改成s3,TZ改成"Asia/Singapore"


只用一条命令就可以做到:
cat <<'EOF' |sed 's:^\(.*\)=\(.*\):s|^\1=.*|\0|g:g'|sed -i -f - .screen3profile
ORACLE_HOME=$ORACLE_BASE/product/9.2
ORACLE_SID=s3
TZ="Asia/Singapore"
EOF


哦耶,再也不用费事调用vi修改文件了,真厉害呀我



Xie Wen (谢文)
Network & Operations,
Multimedia Applications & Services (MDB)
MOTOROLA Inc.
NO.104 mail box, 8th floor, Motorola Tower,
No. 1 Wang Jing East Road, Chao Yang District,
Beijing 100102 P. R. China
e-mail wenxie at motorola.com



-fin-

No comments:

Website Analytics

Followers