troubleshooting Question

grub2 scripting. looking for complete documentation in order to sort items automatically

Avatar of skullnobrains
skullnobrains asked on
Operating SystemsShell ScriptingInstallation
9 Comments2 Solutions2010 ViewsLast Modified:
hello all

i'm trying to do various stuff in grub2 shell but i have a hard time finding proper documentation.

---
Q1

anybody knows where to find a proper exhausive documentation containing namely the supported syntaxes for commands such as regexp and test ? ( which are not available in any of the pages i visited at gnu.org and namely not in http://www.gnu.org/software/grub/manual/html_node/Shell_002dlike-scripting.html )

---
Q2

i have a script that detects available kernels and provides a boot entry for each of them with the corresponding initrd.

i have a hard time to sort the kernel by reverse version order :
- i have no idea if a sort command is available and anyway it does not seem like pipes are supported so it probably would be useless
- i tried various shell syntaxes for the test command but i'm only able to sort numerically using "test NUMBER -gt NUMBER" which work for decimal numbers but will not allow version comparison (i'd need to compare stuff such as 3.8.1-11)
- i have no idea what kind of string manipulation functions are available other than "regexp" and i only know the basic usage since i have yet to find where it is documented
- there migh be a way to list files matching a pattern and output them sorted somehow but i have not found it yet

obviously i can parse the major, minor, sub-minor and whatever you would call the last number, store them into as many variables and use a bunch of if-else comparisons to reach this goal

but it is a major pita and it is not generic enough since it will not allow to compare versions such as 11a with 11b (quite useless for linux kernels but i'd like it more generic)

i'd also be interested in a sort based on mtime or ctime for filesystems that handle it but i have no idea if/how that would be supported in grub shell

i am NOT interested by solutions that involve using a shell script to write grub.cfg : this is both trivial and not what i'm looking for

---

thanks for any hints you can provide
ASKER CERTIFIED SOLUTION
skullnobrains

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 2 Answers and 9 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 9 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros