我一直在尝试编写脚本:
EFIDIR=/Volumes/EFI
KEXTDEST=$EFIDIR/EFI/CLOVER/kexts/Other
if [[ -d $EFIDIR/EFI/CLOVER/kexts/10.* ]]; then
echo "Directory found."
if [[ -d $EFIDIR/EFI/CLOVER/kexts/10.*/*.kext ]]; then
echo "Kext(s) found."
cp -R $EFIDIR/EFI/CLOVER/kexts/10.*/*.kext $KEXTDEST
fi
rm -R $EFIDIR/EFI/CLOVER/kexts/10.*
fi
我想检查是否有任何以“ 10”开头的文件夹。(可以是10.10、10.11 ...等)存在,则如果这些文件夹中的任何一个包含以(.kext)结尾的文件夹都存在...请复制到目标文件夹。
如何以正确的方式编写?
谢谢。
试试这个:
EFIDIR=/Volumes/EFI
KEXTDEST=$EFIDIR/EFI/CLOVER/kexts/Other
for each in $(find $EFIDIR/EFI/CLOVER/kexts/ -name "10.*" -type d); do
echo "Directory found."
for innerdir in $(find $each -name "*.kext" -type d); do
echo "Kext(s) found."
cp -R $innerdir $KEXTDEST
done
rm -R $each
done
find $EFIDIR/EFI/CLOVER/kexts/ -name "10.*" -type d
会查找以in-type d
开头的目录(),如果找到,则会遍历循环中的每个目录。10.*
$EFIDIR/EFI/CLOVER/kexts
for
内部for
循环查找以name开头的目录*.kext
。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句