Counting commands frequency

I'd like to create a script that keeps track of the commands used.
For example:

count ls ps

and from now on whenever I use ls or ps a counter is increased.
I want that after the command count has been activated a session starts(here I can use any commands) and I want to stop the session with a special command(quit for example).
In the end I want to print the result.
I'm a beginner in shell scripting and I don't know how to allow the shell continuing his work after my command has started.

Thank you in advance.

Couple of ways to approach that.

If you are using bash, and have a reasonably large history file set, you can grep the count from "history"

You could also turn on system accounting - "accton".

Thank you.
But I don't know how write the command.
grep "ls" history doesn't work.

history |awk '$1=" "' |sort |uniq -c |sort -n

What does awk actually do?
I read that combines grep and sed commands but I don't understand this '$1=" "'.
It works only if I don't create a script.
What should I do to make a working script of that code?

Thank you anyway.

history command will give both order number and commands, such as:

  10  find . -type d 
   11  ls

with awk '$1=" "', it will remove the first column.