I am writing a small script that should run a program that displays several lines and then displays the number of these lines. However, the program may take several seconds, and I would prefer not to run it twice, once for output, and another for counting.
I can run the program twice:
#!/bin/bash
count=$(program-command | wc -l)
program-command
printf "$count lines"
Is there a way to get an account and withdraw only when you run the program once? This output has formatting, so it’s ideal that the formatting (colors) be preserved.
steel source
share