breakdown sed replace into multiple lines

This commit is contained in:
kneutron 2022-04-14 12:32:08 -05:00 committed by GitHub
parent 8e91c13251
commit c423466b89
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,9 +1,20 @@
#!/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 '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/'
|sed "$subst"
exit;