quick script for sorting and deleting rpms
This commit is contained in:
parent
55f7720982
commit
b2b76a729a
1 changed files with 25 additions and 0 deletions
25
tools/delete_old_rpm.sh
Executable file
25
tools/delete_old_rpm.sh
Executable file
|
@ -0,0 +1,25 @@
|
|||
#!/bin/bash
|
||||
|
||||
####
|
||||
#
|
||||
# quick script that takes all rpm in the current directory
|
||||
# and delete the smaller version when several versions of
|
||||
# a same package exists
|
||||
#
|
||||
# Slow and not error-less
|
||||
#
|
||||
####
|
||||
|
||||
for file in *.rpm ; do
|
||||
regex='(.*)-[^-]+-[^-]+\.rpm'
|
||||
if [[ $file =~ $regex ]] ; then
|
||||
pkg_name=${BASH_REMATCH[1]}
|
||||
regex_same="$pkg_name-[^-]+-[^-]+\.rpm"
|
||||
for same_pkg in *.rpm ; do
|
||||
if [[ $same_pkg =~ $regex_same && `vercmp $file $same_pkg` -gt 0 ]] ; then
|
||||
rm $same_pkg
|
||||
echo $same_pkg removed
|
||||
fi
|
||||
done
|
||||
fi
|
||||
done
|
Loading…
Reference in a new issue