Search Results

Search: Posts Made By: awil
2,152
Posted By RudiC
For more fields per line tryawk ' ...
For more fields per line tryawk ' {B[$2]++
for (i=4; i<=NF; i++) A[$2, i]+=$i
N=NF}
END {for (j in B) {printf "%s ", j
...
2,152
Posted By SriniShoo
awk '{a[$2] += $4; b[$2] += $5} END {for(x...
awk '{a[$2] += $4;
b[$2] += $5}
END {for(x in a)
{print x "\t" a[x] "\t" b[x]}}' inputfile
If you want to maintain the input order
awk '{if(!($2 in b))
{a[++n] = $2};
b[$2] += $4;...
1,138
Posted By clx
If the first field length is fixed (4 char long...
If the first field length is fixed (4 char long alphanumeric with uppercase), one way could be

sed 's/^\([A-Z0-9]\{4\}\).* *\(.*\)/\1 \2/' file

If you are not sure about the length, the awk...
1,138
Posted By Scrutinizer
Try using the inverse of the spacing characters: ...
Try using the inverse of the spacing characters:
sed 's/|[^[:blank:]]*//' file
2,440
Posted By vidyadhar85
You can use awk command to get the desired...
You can use awk command to get the desired output.. regarding ??? not sure what inbtw process happening in your script..


awk '{print $1" "$1" "$4}' Input1.txt
7,253
Posted By Jotne
sed have no loop command, use awk awk -F, '{for...
sed have no loop command, use awk
awk -F, '{for (i=1;i<=NF;i+=2) printf "%s,%s ",$i,$(i+1);print ""}' inputfile
A,A B,C D,R
C,R A,A B,R
R,D A,R B,R
Forum: Programming 02-10-2013
2,151
Posted By durden_tyler
I don't quite understand your implementation in...
I don't quite understand your implementation in Python, but I do understand your problem. A suggested algorithm is as follows:


(1) Read a line, split it by Tabs and then determine if the first...
1,645
Posted By pamu
Try .... awk 'function decide_num(y) { ...
Try ....

awk 'function decide_num(y) {
if(X[y,"A"] > 5){p=1}else{p=0}
if(p == 0){sub("AA","2",$y);sub("AB","1",$y);sub("BB","0",$y)}else{sub("BB","2",$y);sub("AB","1",$y);sub("AA","0",$y)} ...
3,152
Posted By Lem
I guess your problem can easily be solved with...
I guess your problem can easily be solved with awk alone, but since I don't know awk... :(

A possible alternative solution can be this one: knowing which is the colums delimiter in your file (if...
3,152
Posted By Scrutinizer
You could also try this awk version: awk ' ...
You could also try this awk version:
awk '
NR==FNR{
if(NR>1){
for(i=1;i<=NF;i++) if($i==-9) A[i]++
m++
}
next
}
{
for(i=1;i<=NF;i++) if(A[i]==m) $i=x
...
3,152
Posted By Lem
Something like: cut -d" " -f 4,6 --complement...
Something like:
cut -d" " -f 4,6 --complement infile >outfile

Then check outfile. If it's fine, then:
mv outfile file
--
Bye
3,152
Posted By Scrutinizer
Try: awk '{$4=$5}NF=4' infile
Try:
awk '{$4=$5}NF=4' infile
1,908
Posted By raj_saini20
awk...
awk 'BEGIN{i=1}{if(a[$1]){a[$1]=a[$1]FS$2;b[$1]=b[$1]FS$3}else{a[$1]=$2;b[$1]=$3;c[i]=$1;i++}}END{for(j=1;j<i;j++){print c[j],a[c[j]],b[c[j]]}}' file
1,908
Posted By msabhi
awk '{a[$1];b[$1""2]=b[$1""2]"...
awk '{a[$1];b[$1""2]=b[$1""2]" "$2;c[$1""3]=c[$1""3]" "$3} END{for(i in a){print i" "b[i""2]" "c[i""3];}}' input_file
1,908
Posted By durden_tyler
$ $ $ cat f7 A1 B1 2 A2 B1 4 A3 B1 7 ...
$
$
$ cat f7
A1 B1 2
A2 B1 4
A3 B1 7
A1 B2 1
A2 B2 10
A3 B2 8
$
$
$ perl -lane 'if (defined $x{$F[0]}) {@{$x{$F[0]}}[1,3] = @F[1,2] }
else { @{$x{$F[0]}}[0,2] = @F[1,2] }
...
Showing results 1 to 15 of 15

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