Greetings.
I need to generate a simple report via Bash (Korn?) with this raw data
Test_Version=V2.5.2
Test_Version=V2.6.3
Test_Version=V2.4.7
Test_Version=V2.5.2
Test_Version=V2.5.2
Test_Version=V2.5.1
Test_Version=V2.5.0
Test_Version=V2.3.9
Test_Version=V2.3.1
Ideally, I’d like to get something like this sorted output
Version Count
...
V2.5.0 1
V2.5.1 1
V2.5.2 3
V2.6.3 1
...
I can sort the output like this (raw data is contained in ASCII files):
find . -name "*.VER" -exec grep "Test_Version" '{}' ';' -print | grep -e "Test_Version" | sort -u
But I can’t figure out how to count my records in a tabular layout. Any idea how could I do that?
Thanks!!
This seems like a job for awk:
Assuming your version information is in the file
versions.txt(you can also not specify a filename, in that caseawkreads from stdin).Explanation:
-F=tellsawkto use the=character as field separator. Each line in your data will be treated as two fields of which only the second is used.$2.ENDis executed after the last line is processed. It shows all the counts for all distinct values of$2.