LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 665|回复: 2

关于文本文件的块的提取,有什么好办法?

[复制链接]
发表于 2006-10-23 14:03:05 | 显示全部楼层 |阅读模式
比如:

debian:/home/lee# ifconfig
eth0      Link encap:Ethernet  HWaddr 00:04:61:A1:E8:6C
          inet addr:192.168.1.33  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: fe80::204:61ff:fea1:e86c/64 Scopeink
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:22295 errors:0 dropped:0 overruns:0 frame:0
          TX packets:20109 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:20967132 (19.9 MiB)  TX bytes:2801453 (2.6 MiB)
          Interrupt:169 Base address:0xd800

lo        Link encapocal Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:12 errors:0 dropped:0 overruns:0 frame:0
          TX packets:12 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:680 (680.0 b)  TX bytes:680 (680.0 b)

ppp0      Link encapoint-to-Point Protocol
          inet addr:222.211.161.160  P-t-P:222.211.160.1  Mask:255.255.255.255
          UP POINTOPOINT RUNNING NOARP MULTICAST  MTU:1492  Metric:1
          RX packets:20236 errors:0 dropped:0 overruns:0 frame:0
          TX packets:19579 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:3
          RX bytes:20398006 (19.4 MiB)  TX bytes:2351499 (2.2 MiB)


有什么方法 定位 段落 "块"?
发表于 2006-10-23 15:53:10 | 显示全部楼层
你只要提取出两个空行之间的内容再配上你所需要的块的开头字符不就可以了?
回复 支持 反对

使用道具 举报

发表于 2006-10-24 23:12:57 | 显示全部楼层
  1. [0 No.1991 huan@huan ~]$ sudo ifconfig -a
  2. eth0      Link encap:Ethernet  HWaddr 00:0D:61:90:56:E8
  3.           inet addr:192.168.1.3  Bcast:192.168.1.255  Mask:255.255.255.0
  4.           inet6 addr: fe80::20d:61ff:fe90:56e8/64 Scope:Link
  5.           UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
  6.           RX packets:7507 errors:0 dropped:0 overruns:0 frame:0
  7.           TX packets:7474 errors:0 dropped:0 overruns:0 carrier:0
  8.           collisions:0 txqueuelen:1000
  9.           RX bytes:6660256 (6.3 MiB)  TX bytes:1218331 (1.1 MiB)
  10.           Interrupt:193 Base address:0xc000
  11. lo        Link encap:Local Loopback
  12.           inet addr:127.0.0.1  Mask:255.0.0.0
  13.           inet6 addr: ::1/128 Scope:Host
  14.           UP LOOPBACK RUNNING  MTU:16436  Metric:1
  15.           RX packets:16 errors:0 dropped:0 overruns:0 frame:0
  16.           TX packets:16 errors:0 dropped:0 overruns:0 carrier:0
  17.           collisions:0 txqueuelen:0
  18.           RX bytes:800 (800.0 b)  TX bytes:800 (800.0 b)
  19. sit0      Link encap:IPv6-in-IPv4
  20.           NOARP  MTU:1480  Metric:1
  21.           RX packets:0 errors:0 dropped:0 overruns:0 frame:0
  22.           TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
  23.           collisions:0 txqueuelen:0
  24.           RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)
  25. [0 No.1992 huan@huan ~]$ sudo ifconfig -a | perl -0000 -nle '{ print ++$i }'
  26. 1
  27. 2
  28. 3
复制代码
perl 认为这是三段
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表