#!/bin/bash

#The library directly from the latest commit (0901e7855f922e770cbfeb58262cb8fded518190)
#of the git repo
. "/home/tal/Documents/grub/util/grub-mkconfig_lib.in"

list=`for i in /boot/vmlinuz-* /boot/vmlinux-* /vmlinuz-* /vmlinux-* /boot/kernel-* ; do
                  if grub_file_is_not_garbage "$i" ; then echo -n "$i " ; fi
             done`

echo "Original List:"
echo "$list" | tr ' ' '\n'

echo "Sorted List:"
while [ "x$list" != "x" ] ; do
  linux=`version_find_latest $list`
  echo $linux
  list=`echo $list | tr ' ' '\n' | grep -vx $linux | tr '\n' ' '`
done

