lrwxrwxrwx 1 deploy users 20 1월 23 18:15 v122 -> /home/files/video122
lrwxrwxrwx 1 deploy users 20 1월 23 18:15 v123 -> /home/files/video123
lrwxrwxrwx 1 deploy users 20 1월 23 18:15 v124 -> /home/files/video124
lrwxrwxrwx 1 deploy users 20 1월 23 18:15 v125 -> /home/files/video125
lrwxrwxrwx 1 deploy users 20 1월 23 18:15 v126 -> /home/files/video126
lrwxrwxrwx 1 deploy users 20 1월 23 18:15 v127 -> /home/files/video127
lrwxrwxrwx 1 deploy users 20 1월 23 18:15 v128 -> /home/files/video128
lrwxrwxrwx 1 deploy users 20 1월 23 18:15 v129 -> /home/files/video129
lrwxrwxrwx 1 deploy users 20 1월 23 18:15 v130 -> /home/files/video130
lrwxrwxrwx 1 deploy users 20 1월 23 18:15 v131 -> /home/files/video131
lrwxrwxrwx 1 deploy users 20 1월 23 18:15 v132 -> /home/files/video132
lrwxrwxrwx 1 deploy users 20 1월 23 18:15 v133 -> /home/files/video133
lrwxrwxrwx 1 deploy users 20 1월 23 18:15 v134 -> /home/files/video134
lrwxrwxrwx 1 deploy users 20 1월 23 18:15 v135 -> /home/files/video135
lrwxrwxrwx 1 deploy users 20 1월 23 18:15 v136 -> /home/files/video136
lrwxrwxrwx 1 deploy users 20 1월 23 18:15 v137 -> /home/files/video137
这些是符号链接。
如果安装了新video138 ~ video150
卷,我必须links v138~v150
对此进行处理。
你能想象一下 bash 魔法吗? (我尝试使用brace expansion
但无法使其工作。)
如果魔术脚本可以自动创建符号链接并检测卷的安装,那就更好了。
答案1
尝试一个简单的for
循环
for Num in {138..150}; do
ln -s "/home/files/video$Num" "v$Num"
done
答案2
和zsh
:
autoload zmv
alias zln='zmv -L'
zln -s '/home/files/video(*)' 'v$1'
或者
zln -s '/home/files/video(<138-150>)' 'v$1'
否则,使用 zsh 或最新版本的 bash 或 ksh93 支持{x..y}
,您可以执行以下操作:
vln() for i do
ln -s "/home/files/video$i" "v$i"
done
vln {138..150}