Skip to main content
added 322 characters in body
Source Link
Kusalananda
  • 355.8k
  • 42
  • 735
  • 1.1k

it is easy to find files according to times you prefer.but for getting the result of that you could use awk like this:

  awk -F\| '!/^\s*$/{if($4=="S:0"){Arr0[$1","$2","$3]+=1} else {Arr1[$1","$2","$3]+=1}}END{for(i in Arr1){print i,",",Arr0[i],",",Arr1[i]}}'

for explanation:

  1. -F|: define | as field seperator

  2. !/^\s*$/: skip empty lines

  3. if(Clause){Statement}else{statement}: clear

  4. END{...}: this block executes when operator riched to EOF


The awk program, pretty-printed:

! /^\s*$/ {
        if ($4 == "S:0")
                Arr0[$1 "," $2 "," $3] += 1
        else
                Arr1[$1 "," $2 "," $3] += 1
}

END {
        for (i in Arr1)
                print i, ",", Arr0[i], ",", Arr1[i]
}

it is easy to find files according to times you prefer.but for getting the result of that you could use awk like this:

  awk -F\| '!/^\s*$/{if($4=="S:0"){Arr0[$1","$2","$3]+=1} else {Arr1[$1","$2","$3]+=1}}END{for(i in Arr1){print i,",",Arr0[i],",",Arr1[i]}}'

for explanation:

  1. -F|: define | as field seperator

  2. !/^\s*$/: skip empty lines

  3. if(Clause){Statement}else{statement}: clear

  4. END{...}: this block executes when operator riched to EOF

it is easy to find files according to times you prefer.but for getting the result of that you could use awk like this:

  awk -F\| '!/^\s*$/{if($4=="S:0"){Arr0[$1","$2","$3]+=1} else {Arr1[$1","$2","$3]+=1}}END{for(i in Arr1){print i,",",Arr0[i],",",Arr1[i]}}'

for explanation:

  1. -F|: define | as field seperator

  2. !/^\s*$/: skip empty lines

  3. if(Clause){Statement}else{statement}: clear

  4. END{...}: this block executes when operator riched to EOF


The awk program, pretty-printed:

! /^\s*$/ {
        if ($4 == "S:0")
                Arr0[$1 "," $2 "," $3] += 1
        else
                Arr1[$1 "," $2 "," $3] += 1
}

END {
        for (i in Arr1)
                print i, ",", Arr0[i], ",", Arr1[i]
}
Source Link

it is easy to find files according to times you prefer.but for getting the result of that you could use awk like this:

  awk -F\| '!/^\s*$/{if($4=="S:0"){Arr0[$1","$2","$3]+=1} else {Arr1[$1","$2","$3]+=1}}END{for(i in Arr1){print i,",",Arr0[i],",",Arr1[i]}}'

for explanation:

  1. -F|: define | as field seperator

  2. !/^\s*$/: skip empty lines

  3. if(Clause){Statement}else{statement}: clear

  4. END{...}: this block executes when operator riched to EOF