ChinaUnix.net
相关文章推荐:

字符串替换

本帖最后由 yshihyu 于 2012-10-22 22:18 编辑 10-19 07:30:00.580 D/ams ( 274): TID:278 .../AMS.cpp:8:\t[code]#! /usr/bin/python f = open("result.txt", "r") o = open("out.txt", "w") for line in f: s = line.strip() print repr(s)[/code]由文件 result.txt 读取的字符串 会有 \t 怎么将 \t 替换成空白? 谢谢

by yshihyu - Python - 2012-10-22 22:15:30 阅读(1151) 回复(2)

相关讨论

求助,文本如下: 33to44A 55to77A 想保留第一个数字,得到: more33 more55

by Eva326 - Perl - 2016-11-21 16:32:10 阅读(749) 回复(7)

本帖最后由 shihyu 于 2015-09-05 00:42 编辑 sed 替换字符串[code].. image:: /_static/SimpleFactory.jpg[/code]image:: 改成 ![]( 没问题, 但能加上 ) ? 最后变成下面字符串 ![](/_static/SimpleFactory.jpg) 谢谢

字符串

by shihyu - Shell - 2015-09-06 14:06:11 阅读(2520) 回复(15)

本帖最后由 biubiuu 于 2015-03-10 11:50 编辑 我要更换网卡0的mac和ip,下面是/etc/network/interfaces 文件的一部分 auto eth0 iface eth0 inet static pre-up ifconfig eth0 hw ether 84:7E:40:EF:D6:C6 address 192.168.2.88 netmask 255.255.255.0 network 192.168.1.0 gateway 192.168.1.1 我是这么做的 ip=192.168.1.1 mac=01:01:01:01:01:01 sed -i -e "0,/^address/s/.*\(a...

替换字符串

by biubiuu - Shell - 2015-04-13 13:37:40 阅读(1676) 回复(11)

将文本中inject_wise 换成inject_win 要求将原文替换,然后生成一个备份文件。 可以用^I or Tie:FILE. 如果不是替换原文件,我的思路是 read $fd1, print $fd2 . 不知道还有没有其他的思路

by fufelixzh - Perl - 2014-11-12 16:33:23 阅读(2087) 回复(3)

我有一个文本 类似 8613302200008,460030902234084,1201,12,600101,2002-03-19 12:00:00,2013-06-29 22:00:50 8613302200009,460030918855095,1001,12,600101,2010-12-30 18:06:51,2011-09-12 05:30:21 我想替换第三列的值,如果是1201则替换成15 ,如果是1001则替换成10,这个应该怎么写? 谢谢~

by lilyok12345 - Shell - 2014-10-17 15:28:12 阅读(2232) 回复(11)

文件如同 common1 port =123 max_client =299 mode =yes common2 port = 345 max_client =44 mode =no 以上是文件内容,现在我需要把common2下面的port值替换成789. 注意:port的值可能不确定,也就是说不能 sed -i 's/345/789/g' file 需要先找到common2 然后找到port,取出其值 然后进行替换

by liysky - Shell - 2012-07-31 16:46:19 阅读(3407) 回复(10)

a=aaaaa 现在想从第二个a开始都替换成b请问应该怎么做?

by 阿尔法cu - Shell - 2012-07-12 15:09:26 阅读(2337) 回复(10)

1: echo 'a\\\' | sed 's/\\\\\\/\\/g' 2: A=`echo 'a\\\' | sed 's/\\\\\\/\\/g'` 我看1是正确的,而2就不正确了。请问如何取得最后的输出字符串?

by done_and_todo - Shell - 2012-06-11 10:17:46 阅读(4778) 回复(6)

怎么可以把文件里的./configure --prefix=/usr替换成变量a的值 变量a中 有符号/和.

by yakezone - Shell - 2012-03-29 15:57:36 阅读(1054) 回复(1)

C:\Program Files (x86)\GnuWin32\bin>sed -i "s/http://www.google-analytics.com/ur chin.js/a/g" 'grep http://www.google-analytics.com/urchin.js -rl /F:/wget1/twist edmatrix.com/documents/current/api' sed: 无法打开文件 ww.google-analytics.com/urchin.js/a/g: No such file or directo ry 我想把http://www.google-analytics.com/urchin.js替换成a,可是一直不能执行,大家帮我看看怎么修改吧

grepsed

by ttkk1024-pb - Linux系统管理 - 2011-11-22 09:35:19 阅读(2848) 回复(5)