If the version of your package always ends with a digit, you could use
rm mypackage-*[0-9].tar.xz
... or you could use some similar way to match the end of the version number that excludes the match of the -fast variant of the package (maybe even just mypackage-*[!t].tar.xz).
If this is not possible, then...
Assuming that you are using a shell, such as bash, which allows the use of extended ksh-style globbing patterns (enabled with shopt -s extglob in bash), you could do
rm mypackage-!(*-fast).tar.xz
The !(*-fast) portion of the filename globbing pattern above would match any string except strings that match *-fast.
This would also work in the zsh shell, if its KSH_GLOB shell option is set (setopt KSH_GLOB). With zsh extended globbing enabled (setopt EXTENDED_GLOB), you could instead use
rm mypackage-^(*-fast).tar.xz
To additionally only delete regular files, add the glob qualifier (.) to the very end of that filename globbing pattern.
In a sh shell, you could use
for name in mypackage-*.tar.xz; do
case $name in (mypackage-*-fast.tar.xz) ;; (*) rm "$name"; esac
done
or,
for name in mypackage-*.tar.xz; do
case $name in (mypackage-*-fast.tar.xz) continue; esac
rm "$name"
done
This iterates over all names that matches mypackage-*.tar.xz, skips the names that additionally matches mypackage-*-fast.tar.xz, and deletes the rest.
xargscan be a bit of a pain if the filenames contain spaces or quotes, by default it treats both specially. find can delete the files itself, either withfind -deleteorfind -exec rm -- {} +– ilkkachu May 24 '20 at 08:19-maxdepth 1to stopfindfrom deleting files from subdirectories. – Kusalananda May 24 '20 at 09:14