ChinaUnix.net
相关文章推荐:

unix shell sed

by tangke [email=mumutouv@gmail.com]mumutouv@gmail.com[/email] 2009-10-18 4.1 s 函数参数 s 表示替换(substitute)文件内字串。其指令格式如下 : [address1[ ,address2]] s/pattern/replacemen/[flag] 对上述格式有下面几点说明 : 函数参数 s 最多与两个位址参数配合。 关於 "s/pattern/replacement/[flag]"(解[12]) 有下面几点说明: pattern : 它为 reguler expression 字串。它表示文件中要被替换的字串。 rep...

by fewlife - Linux文档专区 - 2009-10-18 09:13:23 阅读(670) 回复(0)

相关讨论

Eg,从字符串mystr中将ttl和time后面的值提取出来,分别赋给两个变量,即128和10.4。 问题是我的server上sed的version很低。 只支持 -e,-f, -n三个options. >sed --version sed: illegal option -- - 如果不使用awk,该如何实现呢? =========================================================================== #!/bin/sh mystr="64 bytes from 123.125.50.22: icmp_seq=1 ttl=128 time=10.4 ms" ...? 非常感谢!!

by thyswallow - Shell - 2010-11-10 03:39:31 阅读(1633) 回复(5)

///////////////shell//////////////////////// shell被单引号括起来之后,特殊符号将失去它转义的意义 先用双引号把$1的转义生效,然后再用单引号 [root@as4 home]# cat hellofun.sh #!/bin/bash #hellofun hello(){ echo $1 echo '$2' echo "$2" } hello aaa bbb [root@as4 home]# ./hellofun.sh aaa $2 bbb [root@as4 home]# //////////////////////AWK/sed///////////////// $awk '{pri...

by xwhbin - Linux文档专区 - 2010-02-01 13:02:24 阅读(983) 回复(0)

截掉文件中的某些特殊段,如下: a文件内容如下 aaaaaa bbbbbb cccccc / sddadfa dfaklga dasfs ) bbbbbb cccccc dddddd / sdf asaf ghhh ) 我想把这个文件中的所有从/到)中的行删除,用shell怎么写? beg=1 for loop in `grep -n '/' a.txt|awk -F: '{print $1}'` do end=`expr $loop - 1` sed -n "${beg},${end}p" a.txt >> b.txt beg=`sed -n "${end},/^)/=" a.txt|tail -1` beg=`expr $beg + 1` done s...

by fjfd - Shell - 2009-09-27 10:24:54 阅读(1409) 回复(8)

shell实例二:sed sed sed '/codfei/p' file //打印所有行重复codfei的行 sed -n '/codfei/p' file //只打印含有codfei的行 sed '3d' file sed '3,$d' file sed '/codfei/d' file //删除的 sed 's/codfei/fei/g' file sed 's/[0-9][0-9]$/&.5/' file sed -n 's/Codfei/fei/gp' file sed -n 's/\(cod\)fei/\1eqwe/p' file //cpd被标记为1 sed 's#3#8#g' file sed -n '/west/,/east/p' file //行到行 sed -e '1,3d' -e...

by zhigaoyes - Linux文档专区 - 2007-04-19 13:08:57 阅读(830) 回复(0)

想在一个.sh文件里面调用sed, 用它把某行的内容改变,行号是一个变量。 #!/bin/sh line=5 sed -n s/CameraIp/CameraIpxx/"${line}"p camera.ini 请达人帮忙改下。

by kf701 - Shell - 2007-03-29 19:39:12 阅读(1248) 回复(3)

sed "s/&&/|/g" test >boss15_yx_cr_grouprela_SZ 1.sed -n '2'p filename 打印文件的第二行。 2.sed -n '1,3'p filename 打印文件的1到3行 3. sed -n '/Neave/'p filename 打印匹配Neave的行(模糊匹配) 4. sed -n '4,/The/'p filename 在第4行查询模式The 5. sed -n '1,$'p filename 打印整个文件,$表示最后一行。 6. sed -n '/.*ing/'p filename 匹配任意字母,并以ing结尾的单词(点号不能少) 7 sed -n / -e '/...

by wangshigeyao - AIX文档中心 - 2008-03-10 15:39:32 阅读(1215) 回复(0)

文本内容如下: disk=/dev/sdb /dev/sdb1 /dev/sdc /dev/sdc1 如果要删除当中指定的任意字符串 例如:要只删除 /dev/sdb1 这个字符串该如何处理。。 谢谢

by cccccc - Shell - 2012-02-18 20:15:10 阅读(14128) 回复(10)

Table of Contents
1. sed简介
2. 定址
3. sed命令
4. 选项
5. 元字符集
6. 实例
7. 脚本

1. sed简介

sed是一种在线编辑器,它一次处理一行内容。处理时,把当前处理的行存储在临时缓冲区中,称为“模式空间”(pattern space),接着用sed命令处理缓冲区中的内容,处理完成后,把缓冲区的内容送往屏幕。接着处理下一行,...

by lantianyu520 - 移动操作系统 - 2011-12-21 08:41:33 阅读(820) 回复(0)

var="Mon 1 day" sed -n '/$var/,//p' test 这个$var 如何传递到sed中,我知道上面那个写法是不对的,在hard quoe里是没法传递的

by horizonhyg - Shell - 2011-08-03 08:31:03 阅读(8967) 回复(2)

num=3 sed -i "$num,$d" text.txt 执行失败 sed: -e expression #1, char 2: unexpected `,'

by hover_sky - Shell - 2011-01-07 23:06:32 阅读(3871) 回复(9)