ChinaUnix.net
相关文章推荐:

shell 替换字符串

本帖最后由 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 阅读(1649) 回复(11)

替换字符串

相关讨论

我有一个文本 类似 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 阅读(2218) 回复(11)

我想问一下如何截取shell字符串里面的关键字呢?比如: 如果字符串中包含关键字"abc"的话,把字符串替换为"abc"。 例如,字符串‘abc123",我把字符串替换为"abc"。 请各位帮帮我,谢谢!

by 奋斗的毛毛虫 - Shell - 2015-10-28 22:04:54 阅读(1707) 回复(7)

[chengmo@localhost ~]$ test='c:/windows/boot.ini' [chengmo@localhost ~]$ echo ${test/\//\\} c:\windows/boot.ini [chengmo@localhost ~]$ echo ${test//\//\\} c:\windows\boot.ini 这两个字符串替换 看不明白 请高手解释下

by jackseans - Shell - 2012-12-06 16:14:17 阅读(816) 回复(0)

本帖最后由 robinylp 于 2011-06-17 20:13 编辑 我有几个IP地址和掩码: 192.168.1.0 23 192.168.45.0 22 192.168.4.0 21 .... 我想替换后面的掩码: 变成 192.168.1.0 0.0.1.255 192.168.45.0 0.0.3.255 192.168.4.0 0.0.7.255 请问哪位大侠有什么好办法吗? 先谢谢了!

by robinylp - Shell - 2011-06-17 21:58:51 阅读(3053) 回复(5)

搜索特定目录下所有特定类型文件中的字符串替换,某些目录需要root权限。 find ./ -name '*.html' | xargs sed -i 's/iso-8859-1/utf-8/g' 本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u3/94441/showart_2096166.html

by 李纳斯 - Linux文档专区 - 2009-11-16 18:35:23 阅读(1099) 回复(0)

想对i字符串作全局替换,把a.c 变成 d.c, 代码 如下: i="a.c b.c a.c" i=${i//#1/d} //请问这句字符串全局替换应该怎么写 echo $i 结果还是 a.c b.c a.c

by jiangwen127 - Shell - 2009-05-29 16:16:45 阅读(3719) 回复(9)

有一个字符串 str="%5BMAC%5D" 现在要将str中的%5B替换成[,将str中的%5D替换成] 请问该怎么做?

by daniel_kohler - AIX - 2010-01-06 20:39:11 阅读(2619) 回复(0)

有一个字符串\r\nstr=\"%5BMAC%5D\"\r\n\r\n现在要将str中的%5B替换成[,将str中的%5D替换成]\r\n\r\n请问该怎么做?

by daniel_kohler - AIX - 2010-01-06 20:39:11 阅读(3883) 回复(0)

如果一个文件里面是一篇文章,想把 句号加空格 这个字符串替换成换行, 是否能用 tr 实现呢?谢谢~

by ZIPRC - Shell - 2004-03-22 12:47:05 阅读(2377) 回复(8)

#!/bin/bash CMINFO=$(/usr/bin/top -d 1 n 2 |/bin/grep ^[CMS]|/usr/bin/tail -3) 上面这个脚本获得的CMINFO变量中有些不可见的特殊字符,有办法替换掉吗?

by tsinghyT - Shell - 2005-11-11 15:18:56 阅读(3098) 回复(2)