[问题] 档案插入字串

楼主: shihyu (shihyu)   2014-01-18 11:12:25
https://gist.github.com/anonymous/8485588
188 trees.c
234 trees.c
328 trees.c
381 trees.c
409 trees.c
453 trees.c
488 trees.c
575 trees.c
617 trees.c
705 trees.c
750 trees.c
801 trees.c
836 trees.c
865 trees.c
882 trees.c
892 trees.c
907 trees.c
1008 trees.c
1058 trees.c
1118 trees.c
1152 trees.c
1167 trees.c
1184 trees.c
1203 trees.c
我针对trees.c 档案上面的行数插入字串, 请问有什么方法比较简单就能达到
目前想法是产生另外一个档案做插入完后在取代档案
谢谢
作者: crazydogx   2014-01-18 22:41:00
sed?
楼主: shihyu (shihyu)   2014-01-18 23:54:00
嗯嗯~我试试看, python 这没办法像sed简单办到吗?
作者: carlcarl (carl)   2014-01-19 12:35:00
是指做法还是用法 做法应该只能写到另外一个档或是把全部都写到memory 再覆写原来的档案
作者: apua (Apua)   2014-01-19 13:44:00
如果在某一行插入字串的话, 行数会变动, 这还会是你要的吗?另外, 即使是用 SED, 实际上还是把整个档案重写过了,跟自己跑程式相比, 执行效率只会更差不会更好又, 如果是 regexp 的话, 可以考虑用 Vim 就好了

Links booklink

Contact Us: admin [ a t ] ucptt.com