How can I loop through and achieve below with passing shell variable in awk
using for
/while
loop?
I have a text file like below.
mark 10 20 30 lawrence 40 22 60 mark 11 12 13 mike 15 16 17 lawrence 21 22 23 mike 31 32 33 mike 41 42 47
I want the output to be like below (2nd column denotes the count of occurrence of each name)
I had one more requirement sorry asking again output would be like
if mark has value 20(in third column), its occurence should be printed in next colmn
if mike has value 32(in third column), its occurence should be printed in next column
if lawrence has value 22(in third column), its occurence should be printed in next column
mark 2 1
mike 3 1
lawrence 2 2
This is what it looks like. I want the text file to be passed as below. Can you please help?
Command i am using now
n=$(date +"%Y%m%d"); LogDataN=`tail -10 "$n".txt` -- my text file which contains the above data A=`echo "$LogDataN" | awk '{ c["$1"]++ } END { for (name in c) print name, c[name] }' ` echo "$A"
sort | uniq -c
really