Deleting versions of scidb arrays

Suppose you have a scidb system where lots of array versions have accumulated,
and you want to clean up old versions of all arrays (retaining only the last 5 versions).

Here is a quick bash script to do the same:

for nm in `iquery -otsv -aq "project(apply(project(list(ns:all), namespace, name), fullnm, namespace + '.' + name), fullnm)"`; 
  do 
  echo $nm; 
  # iquery -aq "remove_versions($nm, keep: 5)"; 
done

Uncomment the line with remove_versions to run the actual version removal.