I am new to linux & bash, and I am working on some different scripts, but I have a few conceptual questions I need answered to help me find the best approach to what I want to do.
-
What is the most efficient way to store data in a bash script, and save it as a file, that another script can speedily parse?
-
What are some good examples of colorful bash menu’s? How can I have a multi-column menu’s in bash?
-
Can I display images in bash or would it be better to send the image info to, let’s say a notify-send, and have it to display any images?
Thank you.
That’s quite a potpourri of questions 🙂
Firstly, the most efficient way to store data in a
bashscript depends entirely on the data and the processing you want done to it. If the processing will be done bybashitself, it’ll probably be faster in abashvariable (size permitting). If external programs likegrep,sedorawkwill be processing it under the direction ofbash, a file may be better.But that’s a very general guideline – you need to analyse both the data and the use of it, especially since how it’s stored in the file is also important. By way of example, I wouldn’t store fixed length records as an XML file if I was processing it in
bashalone, since that means I’d have to write a whole lot of XML processing code for the shell. I’d probably just store it as fixed length records in a flat file.Secondly, I have no examples for you, as
bashtends to either be a command-line driven thing or, at most, a very simple menu-based thing. It’s not generally used for fancy UI work.And you can quite easily have multi-column menus, the simplest form being something like:
Lastly,
bashitself has no support for displaying images any more complicated than ASCII art:So, if you need something more complex than that, you’ll probably be passing it off to an external program.