I have been struggling to find a code that will give me the sum of the first digit for all (1,2,3,...,9) numbers individually from a text file. I also want to adapt/modify that code for the second and two-first digits. Is anyone able to help? What I have done so far is: For the first digit: fgrep -oE "[[:digit:]]{1,}" 'filename' | grep "^1"| wc -l For the second digit: fgrep -oE "[[:digit:]]{2,}" 'filename' | grep "^1"| wc -l
In order to get it for the other digits (2,3,....,9) I modify "^1" to e.g. "^2" and so on.... I am pretty sure the results I get for the second digit formula are definitely wrong.... I need urgend help, thanks! :)