That's not a Heroku command, you need to use the Heroku CLI
heroku domains:add www.example.com
or do it from the web dashboard.
You then need to setup a CNAME record with your DNS provider to set www.example.com to example.herokuapp.com
Question
Trying to host a custom domain with Heroku. i have putting the following into terminal -
CNAME www.example.com example.herokuap.com
but I keeping getting the following error
-bash: CNAME: command not found
help
Solution
That's not a Heroku command, you need to use the Heroku CLI
heroku domains:add www.example.com
or do it from the web dashboard.
You then need to setup a CNAME record with your DNS provider to set www.example.com to example.herokuapp.com