Search Results

Search: Posts Made By: Diya123
1,629
Posted By Chubler_XL
I'm a little concerned with your solution Yoda. ...
I'm a little concerned with your solution Yoda.

Is it guaranteed that the totals printed are going to match the headings, i.e. will for (k in H) be in the same order as for (k in R)?

Also...
1,629
Posted By Yoda
An awk approach: awk ' NR == 1 { ...
An awk approach:
awk '
NR == 1 {
for ( i = 1; i <= NF; i++ )
{
A[i] = $i
H[$i]
}
...
1,659
Posted By Scrutinizer
Try something like: awk -F\| 'NR==FNR{A[$1]=$2;...
Try something like:
awk -F\| 'NR==FNR{A[$1]=$2; next} {print $1, A[">" $1]}' file2 file1

ABC chr15:176578-187678[-]: ['CCTGCGT']
XYZ
PQR chr3:14567-15866[+]: ['CCTYHGV','TLKJNWYT',TTGCDGT']
...
1,266
Posted By migurus
this script will summarize columns per first key...
this script will summarize columns per first key column;


awk '{ key[$1]=$1; col1[$1]+=$2; col2[$1]+=$3; col3[$1]+=$4; col4[$1]+=$5; }
END{ for(x in key) print x, col1[x], col2[x], col3[x],...
1,667
Posted By bartus11
awk '{n=split($2,a,"_");split($3,b,"_");for...
awk '{n=split($2,a,"_");split($3,b,"_");for (i=1;i<=n;i++) print $1,a[i],b[i]}' file
1,085
Posted By rdcwayx
awk '{a[int($2/10)*10]++}END{for (i in a) print i...
awk '{a[int($2/10)*10]++}END{for (i in a) print i "-" i+10, a[i]|"sort -n"}' infile

Some updates based on Chubler_XL's code below

awk '{a[int($2/10)*10]++}END{for (i=0;i<100;i+=10) print i+1...
1,085
Posted By Chubler_XL
Slight improvement - ensure zero counts are...
Slight improvement - ensure zero counts are printed, no need to call external sort:

awk '{a[int($2/10)]++}END{while(++i<11) print i*10-9 "-" i*10, 0+a[i-1]}' infile
Showing results 1 to 7 of 7

 
All times are GMT -4. The time now is 08:45 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy