红联Linux门户
Linux帮助

请教sed命令

发布时间:2015-07-18 14:19:33来源:红联作者:hudengke718
sed -ir '/0x0000001b/s/(value = ").*"/\1HUNCT"/' hw_boardinfo

这个命令是怎么解读的。
hw_boardinfo文件内容
obj.id = "0x00000001" ; obj.value = "2";
obj.id = "0x00000002" ; obj.value = "485754437F67A61D";
obj.id = "0x00000003" ; obj.value = "";
obj.id = "0x00000004" ; obj.value = "";
obj.id = "0x00000005" ; obj.value = "";
obj.id = "0x00000006" ; obj.value = "";
obj.id = "0x00000007" ; obj.value = "021WQL2SE4005693";
obj.id = "0x00000008" ; obj.value = "21500820702SE490080
obj.id = "0x00000009" ; obj.value = "";
obj.id = "0x0000000a" ; obj.value = "D8:49:0B:7F:67:A6";
obj.id = "0x0000000b" ; obj.value = "D8:49:0B:7F:67:AC";
obj.id = "0x00000022" ; obj.value = "D8:49:0B:7F:67:AD";
obj.id = "0x00000023" ; obj.value = "D8:49:0B:7F:67:AE";
obj.id = "0x00000024" ; obj.value = "D8:49:0B:7F:67:AF";
obj.id = "0x0000002d" ; obj.value = "";
obj.id = "0x0000002e" ; obj.value = "";
obj.id = "0x0000002f" ; obj.value = "";
obj.id = "0x00000030" ; obj.value = "";
obj.id = "0x0000000c" ; obj.value = "D8:49:0B:7F:67:A7";
obj.id = "0x0000000d" ; obj.value = "D8:49:0B:7F:67:A8";
obj.id = "0x0000000e" ; obj.value = "D8:49:0B:7F:67:A9";
obj.id = "0x0000000f" ; obj.value = "D8:49:0B:7F:67:AA";
obj.id = "0x00000010" ; obj.value = "D8:49:0B:7F:67:AB";
obj.id = "0x00000011" ; obj.value = "D8:49:0B:7F:67:B0";
obj.id = "0x00000012" ; obj.value = "D8:49:0B:7F:67:B1";
obj.id = "0x00000013" ; obj.value = "D8:49:0B:7F:67:B2";
obj.id = "0x00000016" ; obj.value = "";
obj.id = "0x00000018" ; obj.value = "0";
obj.id = "0x00000019" ; obj.value = "37300D8490B7F67A6";
obj.id = "0x0000001a" ; obj.value = "E8C";
obj.id = "0x0000001b" ; obj.value = "HUNCT";
obj.id = "0x0000001c" ; obj.value = "1";
obj.id = "0x0000001d" ; obj.value = "1";
obj.id = "0x0000001e" ; obj.value = "1";
obj.id = "0x0000001f" ; obj.value = "1";
obj.id = "0x00000020" ; obj.value = "";
obj.id = "0x00000021" ; obj.value = "0";
obj.id = "0x00000025" ; obj.value = "";
obj.id = "0x00000026" ; obj.value = "";
obj.id = "0x00000027" ; obj.value = "";
obj.id = "0x00000028" ; obj.value = "";
obj.id = "0x00000029" ; obj.value = "";
obj.id = "0x0000002a" ; obj.value = "";
obj.id = "0x0000002b" ; obj.value = "";
obj.id = "0x0000002c" ; obj.value = "";
obj.id = "0x00000031" ; obj.value = "NOCHOOSE";



Usage: sed [-efinr] SED_CMD [FILE]...

Options:
-e CMD Add CMD to sed commands to be executed
-f FILE Add FILE contents to sed commands to be executed
-i Edit files in-place (else sends result to stdout)
-n Suppress automatic printing of pattern space
-r Use extended regex syntax

If no -e or -f, the first non-option argument is the sed command string.
Remaining arguments are input files (stdin if none).


求大神指点下。我查阅了正则表示式和扩展正则表达式硬是没看懂这句话的意思!
文章评论

共有 6 条评论

  1. chenxunaizy 于 2016-03-02 15:27:29发表:

    sed -ir '/0x0000001b/s/\(value = "\).*"/\1HUNCT"/' hw_boardinfo
    这样才是正确的吧

  2. fangzhan9527269 于 2015-11-06 19:17:39发表:

    推荐新手读下《Linux就该这么学》,里面包含了Linux基础技术知识以及所有红帽RHCSA+RHCE的考点知识点。
    书籍可以在线学习,挺方便的~ http://www.linuxprobe.com/

  3. skf饭饭 于 2015-09-29 13:20:40发表:

    推荐新手Linux学员看下《Linux就该这么学》,确实不错的Linux教材。(e:e2shttp://www.linuxprobe.com/

  4. Kttlon 于 2015-07-19 16:09:26发表:

    后面的能打出来的是神级别啊

  5. hudengke718 于 2015-07-18 20:38:35发表:

    s/ 后面有个\1这个意思没看出来。其余的看懂了。

  6. hudengke718 于 2015-07-18 17:38:27发表:

    求高人指点啊