【发布时间】:2012-01-07 22:49:43
【问题描述】:
这是我的输入文件..
[root@localhost scripts]# cat ip6hdr.txt | xargs -n4
6000 0000 005C 3320
2001 0000 0000 0000
0000 0000 0000 0100
2001 0000 0000 0000
0000 0000 0000 0200
我想将文件第一行的最后两位数字(即20)更改为00。
我试过这个..
cat ip6hdr.txt | xargs -n4 | sed '1,1s/\([0-9]*\) \([0-9]*\) \([0-9]*\) \([0-9][0-9]\)\([0-9][0-9]\).*/\1 \2 \3 \400 /'
以前它在 ubuntu 上运行良好,现在在 bash 脚本中无法在 fedora 上运行
我没有理由为什么它可以在一个系统上运行而不是在另一个系统上运行..
[root@localhost scripts]# sed --version
GNU sed version 4.1.5
Copyright (C) 2003 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE,
to the extent permitted by law.
如果可能的话,建议我一些替代方案..
【问题讨论】:
-
检查您的 sed 版本,即
sed --version。还有为什么复杂的表达式,为什么不是sed '1s/..$/00/'?祝你好运。 -
您的问题是什么?涉及的 sed 版本有哪些?
-
@shellter 感谢并为那个简单的 +1 ..