-
Notifications
You must be signed in to change notification settings - Fork 14
/
multiple-sed-example.sh
51 lines (42 loc) · 1.6 KB
/
multiple-sed-example.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/bin/bash
# convert short disk names to long OTF, should also work fine with zpool iostat
# yes, this works without line continuation :)
subst='s/sdp/ata-ST4000VN000-1H4168_Z3073Z7/;
s/sdo/ata-ST4000VN000-1H4168_Z3076XV/;
s/sdn/ata-ST4000VN008-2DR166_ZDHB3DR/;
s/sdm/ata-ST4000VN008-2DR166_ZDHB41B/;
s/sdd/ata-ST4000VN008-2DR166_ZDHBCLL/;
s/sdc/ata-ST4000VN008-2DR166_ZDHBDGP/'
# awk NF omits blank lines
zpool status -v \
|awk 'NF>0' \
|sed "$subst"
exit;
Given:
pool: zseatera4
state: ONLINE
config:
NAME STATE READ WRITE CKSUM
zseatera4 ONLINE 0 0 0
raidz2-0 ONLINE 0 0 0
sdc ONLINE 0 0 0
sdd ONLINE 0 0 0
sdp ONLINE 0 0 0
sdo ONLINE 0 0 0
sdn ONLINE 0 0 0
sdm ONLINE 0 0 0
errors: No known data errors
Outputs:
pool: zseatera4
state: ONLINE
config:
NAME STATE READ WRITE CKSUM
zseatera4 ONLINE 0 0 0
raidz2-0 ONLINE 0 0 0
ata-ST4000VN008-2DR166_ZDHBDGP ONLINE 0 0 0
ata-ST4000VN008-2DR166_ZDHBCLL ONLINE 0 0 0
ata-ST4000VN000-1H4168_Z3073Z7 ONLINE 0 0 0
ata-ST4000VN000-1H4168_Z3076XV ONLINE 0 0 0
ata-ST4000VN008-2DR166_ZDHB3DR ONLINE 0 0 0
ata-ST4000VN008-2DR166_ZDHB41B ONLINE 0 0 0
errors: No known data errors