通过 shell 脚本删除一堆断开连接的 LUN(正则表达式问题)

通过 shell 脚本删除一堆断开连接的 LUN(正则表达式问题)

我的脚本有问题,不想在更改 LUN 编号的情况下运行相同的程序 200 次。从所有到 LUN 的路径中删除多路径设备,运行echo 1 > /sys/bus/scsi/devices/${H:B:T:L}/delete (其中 H = host:B = bus:T = target:L = lun)例如,2:0:3:1 到 2:0:3:49

让我们检查一下我们的 LUN:

lsscsi


[2:0:3:33]   disk    NETAPP   LUN C-Mode       9700  /dev/sdbt
[2:0:3:34]   disk    NETAPP   LUN C-Mode       9700  /dev/sdbv
[2:0:3:35]   disk    NETAPP   LUN C-Mode       9700  /dev/sdbw
[2:0:3:36]   disk    NETAPP   LUN C-Mode       9700  /dev/sdby
[2:0:3:37]   disk    NETAPP   LUN C-Mode       9700  /dev/sdca
[2:0:3:38]   disk    NETAPP   LUN C-Mode       9700  /dev/sdcc
[2:0:3:39]   disk    NETAPP   LUN C-Mode       9700  /dev/sdce
[2:0:3:40]   disk    NETAPP   LUN C-Mode       9700  /dev/sdcg
[2:0:3:41]   disk    NETAPP   LUN C-Mode       9700  /dev/sdci
[2:0:3:42]   disk    NETAPP   LUN C-Mode       9700  /dev/sdck
[2:0:3:43]   disk    NETAPP   LUN C-Mode       9700  /dev/sdcm
[2:0:3:44]   disk    NETAPP   LUN C-Mode       9700  /dev/sdco
[2:0:3:45]   disk    NETAPP   LUN C-Mode       9700  /dev/sdcp

清理脚本:

for IP in {1...45} ; do 'echo 1 > /sys/bus/scsi/devices/2:0:3:$IP/delete'; done

收到错误:

-bash: echo 1 > /sys/bus/scsi/devices/2:0:3:$IP/delete: No such file or directory

再试一次:

for IP in {1...45} ; do "echo 1 > /sys/bus/scsi/devices/2:0:3:$IP/delete"; done

收到错误:

-bash: echo 1 > /sys/bus/scsi/devices/2:0:3:{1...45}/delete: No such file or directory

如何隔离知识产权使其在该请求中发挥作用?

答案1

相关内容