How to write a bash script that counts the number of performed commands?


Warning: count(): Parameter must be an array or an object that implements Countable in /home/styllloz/public_html/qa-theme/donut-theme/qa-donut-layer.php on line 274
0 like 0 dislike
8 views
Necessary when closing the console will display a message with the number of performed commands for the current session, the history command does not work in bash script, what are the other options?
by | 8 views

2 Answers

0 like 0 dislike
Make a variable and put it in after each command.
var=$((var+1)) ((var=var+1)) ((var+=1)) ((var++)) let "var=var+1" let "var+=1" let "var++"
by
0 like 0 dislike
works, Google "getting data from command output" :)

but it is better to read in the script ~/.bash_history directly.
by

Related questions

0 like 0 dislike
4 answers
asked Apr 10, 2019 by aleksmanson
0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
110,608 questions
257,186 answers
0 comments
35,458 users