Here is the problem; you need to print a single line filled with dashes. Will you just echo 80 dashes or write a beautiful loop for it?
$ echo "--------------------------------------------------------------------------------"$ n=0 ; while [ $n -lt 80 ] ; do printf "-" ; n=$(($n+1)) ; done ; echoBoth give the same result, but the easy solution is faster. Result from the machine where I am working on:
| Test | Easy way | Aesthetics way |
| Time to execute: | 0.000 seconds | 0.039 seconds |
| Bytes on disk | 88 | 70 |
| Complexity level | 1 | 7 |
| System calls | 37 | 657 |
| lines printed in 1 minute | 1471371 | 18318 |
The numbers show that simplicity is more efficient.
Comments
in bash: for((i=0; i < 80;
in bash:
for((i=0; i < 80; i++)); do echo -n -; done ; echo
+5 insightful. Simplicity,
+5 insightful. Simplicity, elegance, beauty, and efficiency are intrinsically linked. To quote Buckminster Fuller:
'When I am working on a problem I never think about beauty. I only think about how to solve the problem. But when I have finished, if the solution is not beautiful, I know it is wrong.'
hmmm, i some times have to
hmmm, i some times have to change code (even mine) and it read faster, easier and is mor understandable, which results in less errors when recoding.
KISS (keep it simple st.... )