shell 字符运算

for i in {97..122}; do ls /dev/sd$(printf \\"$(printf %03o "$[i+1]")"); done

[root@bogon ~]# for i in {97..122}; do ls /dev/sd$(printf \"$(printf %03o "$[i+1]")"); done
/dev/sdb
/dev/sdc
/dev/sdd
/dev/sde
/dev/sdf
/dev/sdg
/dev/sdh
/dev/sdi
/dev/sdj
/dev/sdk
/dev/sdl
/dev/sdm
/dev/sdn
/dev/sdo
/dev/sdp
/dev/sdq
/dev/sdr
/dev/sds
ls: cannot access '/dev/sdt': No such file or directory
ls: cannot access '/dev/sdu': No such file or directory
ls: cannot access '/dev/sdv': No such file or directory
ls: cannot access '/dev/sdw': No such file or directory
ls: cannot access '/dev/sdx': No such file or directory
ls: cannot access '/dev/sdy': No such file or directory
ls: cannot access '/dev/sdz': No such file or directory
ls: cannot access '/dev/sd{': No such file or directory

for i in {1..13}; do mkfs.xfs /dev/sd$(printf \\"$(printf %03o "$[i+96]")") -L DISK$[4+$i] -f;done\
for i in {7..22};do echo " LABEL=DISK$i   /mnt/DISK$i                     xfs     defaults,noatime,nofail   0 2" >> /etc/fstab;done

参考:
https://unix.stackexchange.com/questions/15139/how-to-print-all-printable-ascii-chars-in-cli

posted @ 2022-10-05 18:14  小黑狐狸1001  阅读(37)  评论(0编辑  收藏  举报