Just annotations of little "how to's", so I know I can find how to do something I've already done when I need to do it again, in case I don't remember anymore, which is not unlikely. Hopefully they can be useful to others, but I can't guarantee that it will work, or that it won't even make things worse.
Rather basic realization on scripting logic, it may be often better to let C programs do "excessive" work than trying to spare them w/ Bash
Tags bash-scripting, logic
"C" stuff will be much faster than scripts, so sometimes even a "dumb" use of a C program will be more optimal (take less time) than trying to sort out a more minimal task for the C program with bash.
Like
versus
I guess it will be quite rare that the solution that has more bash script stuff yields a better result, maybe scenarios where grep searching through all files could produce way more performance-bottlenecking hard disk reading, while a bash logic could circumvent that significantly.
Apparently the "logic" could be as rudimentary/basic as merely a loop that gives "grep" only a file to work at a time, and "breaking" the loop once the thing to be grepped is found (skipping needlessly searching other files), and still perform worse.
Like
Code:
grep -h -m 1 THING-TO-GREP index_*
Code:
< ... some bash-script logic that tries to figure out the most likely index_NNNN files so grep has only to work with a few, not all ... > grep -h -m 1 THING-TO-GREP ${most_likely_index_files}
Apparently the "logic" could be as rudimentary/basic as merely a loop that gives "grep" only a file to work at a time, and "breaking" the loop once the thing to be grepped is found (skipping needlessly searching other files), and still perform worse.
Total Comments 1
Comments
-
Mostly I use bash as a way to "glue" different (compiled) programs together. bash for quick changes, binaries for speed and for better string handling.
Posted 06-06-2023 at 04:43 PM by jr_bob_dobbs