As part of learning/experimenting with bash I wrote a script with which you can install android-tools-adb
package. apt
output is written to log file. Before and after I run apt install
, I check number of lines in log file, so I can check lines later for errors:
OUT=~/script_output-$(date +"%Y_%m_%d_%H_%M_%S").log
echo "" > "$OUT"
ln_before=$(wc --lines < "$OUT")
(sudo apt install android-tools-adb --yes) &>> "$OUT"
ln_after=$(wc --lines < "$OUT")
#$ln_after=66
after apt
is finished, I can see in log file 87 lines. However, wc --lines
returns 66. I understand it's because of lines starting with 'Reading dataase ...'
which are updated on the same line in terminal. Gedit recognizes correctly that it has 87 lines. How can I get correct number of lines from log file ?
Note this is not full script, just part of one function.