Search Results

Search: Posts Made By: DerSeb
1,985
Posted By balajesuri
Perl, ok? perl -lane 'print "$F[0] ",...
Perl, ok?
perl -lane 'print "$F[0] ", int(rand($F[2]-$F[1])) + $F[1]' file
1,611
Posted By yinyuemi
Hope this could help you, awk...
Hope this could help you,

awk 'NR%4==2{sub("T*|A*","");l=length($0)}NR%4==0{$0=substr($0,length($0)-l+1)}1' file
3,815
Posted By Chubler_XL
As the file is already sorted you can do it in 1...
As the file is already sorted you can do it in 1 pass:

awk 'function p(){for(I=C;I;I--)print R" "T/C} $1!=R{C=T=p()} {R=$1;C++;T+=$2} END{p()}' infile
3,815
Posted By Scrutinizer
awk...
awk 'NR==FNR{A[$1]++;B[$1]+=$2;next}{$2=B[$1]/A[$1]}1' infile infile
3,815
Posted By pravin27
Try this, awk '{if(! a[$1])...
Try this,

awk '{if(! a[$1]) {a[$1]=$2;j=0;b[$1]=++j}else{a[$1]=a[$1]+$2;b[$1]=++j}} END{for (i in a) {for(l=1;l<=b[i];l++){print i,a[i]/b[i]}}}' inputfile
3,815
Posted By m.d.ludwig
The awk script:{ l[NR] = $1; n[$1]++; s[$1] +=...
The awk script:{ l[NR] = $1; n[$1]++; s[$1] += $2; }
END {
for (i in n) { a[i] = s[i] / n[i]; }
for (i = 1; i <= NR; i++) { print l[i], a[l[i]]; }
}Results in:Test1 7.5
Test1 7.5
Test2...
4,920
Posted By Franklin52
If you have problem with the used memory you can...
If you have problem with the used memory you can try this:
awk '{
getline line < "file1"
gsub("[A-Za-z]","",line)
n=length(line)
$(n+1)="_"
sub(" _.*","")
}1' file2
4,920
Posted By rdcwayx
awk 'NR==FNR{T[NR]=length($1);next} {if...
awk 'NR==FNR{T[NR]=length($1);next}
{if (FNR%2) {print $0}
else {{for (i=1;i<T[FNR];i++) printf "%s ",$i}; printf "\n"}
}' file1 file2
Showing results 1 to 8 of 8

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