paranoidandroid | Les noms de serveurs étant normés (avec un "V_" en tant que préfixe), je les cherche dans chaque ligne, si je ne les trouve pas, j'affiche le dernier nom de serveur trouvé, et j'affiche toute la ligne avec). Merci pour la solution en sed au passage, je ne "script" que très rarement, je pense avoir déjà fait cette exercice en perl il y a plusieurs années ... plutôt simple comme problème.
La solution est peut être pas sexy, mais c'est fonctionnel, cf plus bas.
Exemple :
Code :
- [para]$ cat viewsexample
- /clusters/cluster-1/exports/storage-views/V_SOP_frsopseinf001:
- (1,VOL_SOP_frsopseinf001-002_001_3B2_T2D,VPD83T3:6000144000000010200d75d20d9929ad,1T)
- (2,VOL_SOP_frsopseinf001-002_002_3B2_T2D,VPD83T3:6000144000000010200d75d20d9929ae,1T)
- (3,VOL_SOP_frsopseinf001-002_003_3B2_T2D,VPD83T3:6000144000000010200d75d20d9929ac,1T)
- /clusters/cluster-1/exports/storage-views/V_SOP_frsopseinf005:
- (1,VOL_SOP_frsopseinf005-006_001_3B2_T2D,VPD83T3:6000144000000010200d75d20d99293b,1T)
- /clusters/cluster-1/exports/storage-views/V_SOP_frsopslapp001:
- (0,VOL_SOP_frsopslapp001_000_3B2_T2D,VPD83T3:6000144000000010200d75d20d992962,128G)
- (1,VOL_SOP_frsopslapp001_001_3B2_T2D,VPD83T3:6000144000000010200d75d20d992964,0.25T)
- /clusters/cluster-1/exports/storage-views/V_SOP_frsopslapp003:
- (0,VOL_SOP_frsopslapp003_000_3B2_T2D,VPD83T3:6000144000000010200d75d20d9929a1,128G)
- (1,VOL_SOP_frsopslapp003_001_3B2_T2D,VPD83T3:6000144000000010200d75d20d9929a2,128G)
- (3,VOL_SOP_frsopslapp003-004_003_3B2_T2D,VPD83T3:6000144000000010200d75d20d9929a0,2G)
- /clusters/cluster-1/exports/storage-views/V_SOP_frsopslapp005:
- /clusters/cluster-1/exports/storage-views/V_SOP_frsopslbdd001:
- /clusters/cluster-1/exports/storage-views/V_SOP_frsopslbdd003:
- (0,VOL_SOP_frsopslbdd003_000_3B2_T2D,VPD83T3:6000144000000010200d75d20d9928c7,128G)
- (1,VOL_SOP_frsopslbdd003_001_3B2_T2D,VPD83T3:6000144000000010200d75d20d9928c9,128G)
- (2,VOL_SOP_frsopslbdd003-004_002_3B2_T0D,VPD83T3:6000144000000010200d75d20d9928b3,128G)
- (3,VOL_SOP_frsopslbdd003-004_003_3B2_T2D,VPD83T3:6000144000000010200d75d20d9928b5,128G)
- (4,VOL_SOP_frsopslbdd003-004_004_3B2_T0D,VPD83T3:6000144000000010200d75d20d9928b7,128G)
- (5,VOL_SOP_frsopslbdd003-004_005_3B2_T0D,VPD83T3:6000144000000010200d75d20d9928b9,8G)
- (6,VOL_SOP_frsopslbdd003-004_006_3B2_T2D,VPD83T3:6000144000000010200d75d20d9928bb,8G)
- (7,VOL_SOP_frsopslbdd003-004_007_3B2_T2D,VPD83T3:6000144000000010200d75d20d9928bd,2G)
- (8,VOL_SOP_frsopslbdd003-004_008_3B2_T0D,VPD83T3:6000144000000010200d75d20d9928bf,2G)
- (10,VOL_SOP_frsopslbdd003-004_010_3B2_T2D,VPD83T3:6000144000000010200d75d20d9928c1,2G)
- (11,VOL_SOP_frsopslbdd003-004_011_X606_T1D,VPD83T3:6000144000000010200d75d20d9928c3,2G)
- (12,VOL_SOP_frsopslbdd003-004_012_3B2_T2D,VPD83T3:6000144000000010200d75d20d9928c5,2G)
- /clusters/cluster-1/exports/storage-views/V_SOP_frsopslbdd005:
- /clusters/cluster-1/exports/storage-views/V_SOP_frsopslbdd007:
- /clusters/cluster-1/exports/storage-views/V_SOP_frsopslbdd009:
- /clusters/cluster-1/exports/storage-views/V_SOP_frsopslweb001:
- (0,VOL_SOP_frsopslweb001_000_3B2_T2D,VPD83T3:6000144000000010200d75d20d99293c,96G)
- (1,VOL_SOP_frsopslweb001_001_3B2_T2D,VPD83T3:6000144000000010200d75d20d99293d,80G)
- /clusters/cluster-1/exports/storage-views/V_SOP_frsopslweb003:
- (0,VOL_SOP_frsopslweb003_000_3B2_T2D,VPD83T3:6000144000000010200d75d20d992940,96G)
- (1,VOL_SOP_frsopslweb003_001_3B2_T2D,VPD83T3:6000144000000010200d75d20d992941,80G)
|
Traitement :
Code :
- [para]$ cat viewsexample | awk '{ if ($0 ~ "V_" ) split($0,viewpath,"/" ) ; else print viewpath[6], $0 }'
- V_SOP_frsopseinf001: (1,VOL_SOP_frsopseinf001-002_001_3B2_T2D,VPD83T3:6000144000000010200d75d20d9929ad,1T)
- V_SOP_frsopseinf001: (2,VOL_SOP_frsopseinf001-002_002_3B2_T2D,VPD83T3:6000144000000010200d75d20d9929ae,1T)
- V_SOP_frsopseinf001: (3,VOL_SOP_frsopseinf001-002_003_3B2_T2D,VPD83T3:6000144000000010200d75d20d9929ac,1T)
- V_SOP_frsopseinf005: (1,VOL_SOP_frsopseinf005-006_001_3B2_T2D,VPD83T3:6000144000000010200d75d20d99293b,1T)
- V_SOP_frsopslapp001: (0,VOL_SOP_frsopslapp001_000_3B2_T2D,VPD83T3:6000144000000010200d75d20d992962,128G)
- V_SOP_frsopslapp001: (1,VOL_SOP_frsopslapp001_001_3B2_T2D,VPD83T3:6000144000000010200d75d20d992964,0.25T)
- V_SOP_frsopslapp003: (0,VOL_SOP_frsopslapp003_000_3B2_T2D,VPD83T3:6000144000000010200d75d20d9929a1,128G)
- V_SOP_frsopslapp003: (1,VOL_SOP_frsopslapp003_001_3B2_T2D,VPD83T3:6000144000000010200d75d20d9929a2,128G)
- V_SOP_frsopslapp003: (3,VOL_SOP_frsopslapp003-004_003_3B2_T2D,VPD83T3:6000144000000010200d75d20d9929a0,2G)
- V_SOP_frsopslbdd003: (0,VOL_SOP_frsopslbdd003_000_3B2_T2D,VPD83T3:6000144000000010200d75d20d9928c7,128G)
- V_SOP_frsopslbdd003: (1,VOL_SOP_frsopslbdd003_001_3B2_T2D,VPD83T3:6000144000000010200d75d20d9928c9,128G)
- V_SOP_frsopslbdd003: (2,VOL_SOP_frsopslbdd003-004_002_3B2_T0D,VPD83T3:6000144000000010200d75d20d9928b3,128G)
- V_SOP_frsopslbdd003: (3,VOL_SOP_frsopslbdd003-004_003_3B2_T2D,VPD83T3:6000144000000010200d75d20d9928b5,128G)
- V_SOP_frsopslbdd003: (4,VOL_SOP_frsopslbdd003-004_004_3B2_T0D,VPD83T3:6000144000000010200d75d20d9928b7,128G)
- V_SOP_frsopslbdd003: (5,VOL_SOP_frsopslbdd003-004_005_3B2_T0D,VPD83T3:6000144000000010200d75d20d9928b9,8G)
- V_SOP_frsopslbdd003: (6,VOL_SOP_frsopslbdd003-004_006_3B2_T2D,VPD83T3:6000144000000010200d75d20d9928bb,8G)
- V_SOP_frsopslbdd003: (7,VOL_SOP_frsopslbdd003-004_007_3B2_T2D,VPD83T3:6000144000000010200d75d20d9928bd,2G)
- V_SOP_frsopslbdd003: (8,VOL_SOP_frsopslbdd003-004_008_3B2_T0D,VPD83T3:6000144000000010200d75d20d9928bf,2G)
- V_SOP_frsopslbdd003: (10,VOL_SOP_frsopslbdd003-004_010_3B2_T2D,VPD83T3:6000144000000010200d75d20d9928c1,2G)
- V_SOP_frsopslbdd003: (11,VOL_SOP_frsopslbdd003-004_011_X606_T1D,VPD83T3:6000144000000010200d75d20d9928c3,2G)
- V_SOP_frsopslbdd003: (12,VOL_SOP_frsopslbdd003-004_012_3B2_T2D,VPD83T3:6000144000000010200d75d20d9928c5,2G)
- V_SOP_frsopslweb001: (0,VOL_SOP_frsopslweb001_000_3B2_T2D,VPD83T3:6000144000000010200d75d20d99293c,96G)
- V_SOP_frsopslweb001: (1,VOL_SOP_frsopslweb001_001_3B2_T2D,VPD83T3:6000144000000010200d75d20d99293d,80G)
- V_SOP_frsopslweb003: (0,VOL_SOP_frsopslweb003_000_3B2_T2D,VPD83T3:6000144000000010200d75d20d992940,96G)
- V_SOP_frsopslweb003: (1,VOL_SOP_frsopslweb003_001_3B2_T2D,VPD83T3:6000144000000010200d75d20d992941,80G)
|
Message édité par paranoidandroid le 05-08-2014 à 18:07:42
|