2017-03-29 96 views
-2
=================================== 
dell1-node1.lvs.local 

Device: t10.ATA_____DENCSTE251M252D0115______________________A09AY011202000268000000 
VSANUUID: 5229819d-8308-e6a3-fea1-0716a6432ecd 
SSD: True 
Capacity: 79830188032 
CapacityUsed: 0 
DiskHealh: OK 

Device: t10.ATA_____ST1000VX0012D1HH162__________________________________S513WZVV 
VSANUUID: 526b1573-6e2e-111e-9748-a67d18a0093f 
SSD: False 
Capacity: 990191288320 
CapacityUsed: 526032830464 
DiskHealh: OK 

=================================== 
dell1-node4.lvs.local 

Device: t10.ATA_____ST2000VX0032D1HH164__________________________________W7208JYX 
VSANUUID: 52219120-9951-3037-a871-11571eccf50e 
SSD: False 
Capacity: 1980382576640 
CapacityUsed: 1337030868992 
DiskHealh: OK 

Device: t10.ATA_____DENCSTE251M252D0115______________________A09AY011210000027000000 
VSANUUID: 52252706-4dcb-c73c-19f5-67719c29d0f6 
SSD: True 
Capacity: 79830188032 
CapacityUsed: 0 
DiskHealh: OK 

=================================== 
dell1-node3.lvs.local 

Device: naa.5000c5008c23ab53 
VSANUUID: 5213b511-11b8-5f64-cb03-5a2d6ad258fa 
SSD: False 
Capacity: 990191288320 
CapacityUsed: 682308403200 
DiskHealh: OK 

Device: naa.5000c5008c23ac7a 
VSANUUID: 5236dc9a-b087-c2d8-2d24-2433218f3352 
SSD: False 
Capacity: 990191288320 
CapacityUsed: 652595953664 
DiskHealh: OK 

Device: naa.5e83a97010008946 
VSANUUID: 52f99ae4-970c-7369-de9d-7b93f0d9b5df 
SSD: True 
Capacity: 79830188032 
CapacityUsed: 0 
DiskHealh: OK 

大家好,我需要這個字符串複製到文件: dell1-node4.lvs.local拆分數據

Device: t10.ATA_____ST2000VX0032D1HH164__________________________________W7208JYX 
VSANUUID: 52219120-9951-3037-a871-11571eccf50e 
SSD: False 
Capacity: 1980382576640 
CapacityUsed: 1337030868992 
DiskHealh: OK 

Device: t10.ATA_____DENCSTE251M252D0115______________________A09AY011210000027000000 
VSANUUID: 52252706-4dcb-c73c-19f5-67719c29d0f6 
SSD: True 
Capacity: 79830188032 
CapacityUsed: 0 
DiskHealh: OK 

然後這個字符串繼續複製到另一個文件:

t10.ATA_____DENCSTE251M252D0115______________________A09AY011210000027000000 
VSANUUID: 52252706-4dcb-c73c-19f5-67719c29d0f6 
SSD: True 
Capacity: 79830188032 
CapacityUsed: 0 
DiskHealh: OK 
+3

請問您能更清楚一點嗎? –

+0

是的,我需要grep之間的字符串「===================================」 –

+0

@AshishK不是真的,你應該注意[如何創建一個最小,完整和可驗證的例子](http://stackoverflow.com/help/mcve) – Jer

回答

0

如果您希望「====」之間的所有內容都存儲在給定的文件中,這將起作用。我也在我的系統上測試過它。祝你好運!具有這樣的文字,以及/=/確實

awk '/dell/{flag=1;next}/=/{flag=0}flag' <filename> > dell1-node4.lvs.local 
  • /dell/匹配線。

  • /dell/{flag=1;next}設置標誌,當文本dell被發現。 然後,它跳過線。

  • /=/{flag=0}找到文本=時取消設置標誌。

  • 最終標誌是一個帶默認動作的模式,它是 print $0:如果標誌等於1該行被打印。