Chinaunix

标题: 请教shell [打印本页]

作者: jason21th    时间: 2003-06-24 11:24
标题: 请教shell
我想写个shell,要实现以下功能

原文件是这样的:
....
console=/etc/console
....


想变成这样:
#console=/etc/console
.....
abcdefg

就是说要在某一句前加一个#
在末尾加一行
各位老大,怎么实现?急
作者: taige    时间: 2003-06-24 11:34
标题: 请教shell
cat >>yourfile <<EOF
abcdefg
EOF

sed 's/^console/#console/' yourfile >/tmp/yourfile.t
mv /tmp/yourfile.t yourfile
作者: jason21th    时间: 2003-06-24 13:27
标题: 请教shell





欢迎光临 Chinaunix (http://bbs.chinaunix.net/) Powered by Discuz! X3.2