It did work fine for me. There's not much complexity in that command, it's just a simple find, select/sort the proper directories, ( instead of awk , a simple
tail -n could have done that), and finally remove them.
Maybe you didn't do a
cd first, or you might need to check your awk version. Please reread carefully O/P's requirement

.