Determine the frequency of each number within a text file

I'd like to determine the frequency that each number occurs within a text file. I know how to do this for a single number, but not for a set or list of numbers. Here's what I have

  grep -o 01 file.txt | wc -l 

Also, it's important that the numbers are two digits instead of 1, meaning that single digit numbers should begin with a 0.

Thank you

how your file looks like ?

here is an excerpt of the file

 
38  51  17  28  39  33  
23  56  43  45  15  07  
08  13  59  17  34  35  
41  54  59  33  05  13  
28  19  29  47  04  05  
44  12  43  24  45  07

is this homework ?

It's not homework, it's me trying to learn.

ok, then read about the below commands

 
tr
sort
uniq 

I wonder how you are going to learn something by asking for solutions here. Without even trying to find a solution yourself you will learn next to nothing from such an endeavour.

First, your "single number solution" works only with one fixed number, which you have to provide beforehand. To find the solutions of arbitrary numbers you will first have to find out which numbers are there, before counting them one by one.

Second, i suggest you read the man page of grep again. The more commands you use to achieve a certain task the more (processor) time it takes. Try to eliminate commands in the pipeline you use.

I hope this helps.

bakunin

Learning a solution to a problem is also learning. It's not that important, I may or may not do it on my own. Thanks for redirecting me away from here.

Best of luck elsewhere!

These forums are for professionals who actually put an effort into solving their work-related problems.

Our members are not here to do your work for you, while you put nearly zero effort into actually solving the problem yourself.