С другой стороны, рассмотрели ли вы использование альтернативного менеджера wifi? Я сам имел некоторые проблемы с нм-апплет, но я установил Wicd из хранилищ, и проблемы просто исчезли.
Вы можете получить Wicd [F1], а затем перезапустить X.
Вот один из способов:
#!/bin/bash
targetDir=/opt/bla/myfiles;
## declare 'releases' as an associative array
declare -A releases
cd "$targetDir"
## Iterate over all directories in $targetDir.
for dir in */; do
## remove the trailing slash
dir="${dir%/}"
## Extract the version string
ver="${dir%%-*}"
## Use the version as the key for the associative array
releases["$ver"]="$dir";
done
## Get the newest version; sort -h understands version numbers
newestVersion=$( printf '%s\n' "${!releases[@]}" | sort -h | tail -n1)
## This is probably not needed as extended globbing should be on by default
shopt -s extglob
## Delete the rest. The '$targetDir/' isn't necessary but it's safer
## just in case we're not actually where we think we are.
rm -rf $targetDir/!("${releases[$newestVersion]}")
Предостережения:
Предполагается, что у вас есть только директории в /opt/bla/myfiles. Он удалит все, кроме каталога последней версии.Вот один из способов:
#!/bin/bash
targetDir=/opt/bla/myfiles;
## declare 'releases' as an associative array
declare -A releases
cd "$targetDir"
## Iterate over all directories in $targetDir.
for dir in */; do
## remove the trailing slash
dir="${dir%/}"
## Extract the version string
ver="${dir%%-*}"
## Use the version as the key for the associative array
releases["$ver"]="$dir";
done
## Get the newest version; sort -h understands version numbers
newestVersion=$( printf '%s\n' "${!releases[@]}" | sort -h | tail -n1)
## This is probably not needed as extended globbing should be on by default
shopt -s extglob
## Delete the rest. The '$targetDir/' isn't necessary but it's safer
## just in case we're not actually where we think we are.
rm -rf $targetDir/!("${releases[$newestVersion]}")
Предостережения:
Предполагается, что у вас есть только директории в /opt/bla/myfiles. Он удалит все, кроме каталога последней версии.