Search Results

Search: Posts Made By: RozenKristal
4,039
Posted By Scrutinizer
awk '{A[$1]} $2~/\./ &&...
awk '{A[$1]} $2~/\./ && sub(/\$/,x,$2){A[$1]+=($3=="paid"?$2:-$2)} END{for(i in A)printf "%s balance: $%.2f\n",i,A[i]}' file1 file2
4,039
Posted By pamu
I am not clear what kind of this requirement it...
I am not clear what kind of this requirement it is.

Here we are not doing any thing to files so that it will impact any thing..

still for your requirement try..

awk 'NR==FNR{A[$0]=0;next}
...
4,039
Posted By rdcwayx
But what's the reason to put file1 first?
But what's the reason to put file1 first?
4,039
Posted By rdcwayx
awk 'NR==FNR{ if ($2~/\$/) {sub(/\$/,"",$2); if...
awk 'NR==FNR{ if ($2~/\$/) {sub(/\$/,"",$2); if (/paid/) {a[$1]+=$2} ;if (/due/) a[$1]-=$2}}
NR>FNR{printf "%s balance:$%.2f \n",$1,a[$1]+0}' file2 file1

CoCo balance:$-10.65
Hiel...
4,039
Posted By pamu
please check file sequence.. it should be ...
please check file sequence.. it should be
file2 file1 file2 should be first.
Please check my previous post.. Just added.. this :)
4,039
Posted By pamu
awk 'NR==FNR{sub("\\$","");s=$2;if($3 ==...
awk 'NR==FNR{sub("\\$","");s=$2;if($3 == "due"){s=0-$2};A[$1]=A[$1]?A[$1]+s:s;next}{print $0,"balance: \$",A[$0]?A[$0]:"0\.00"}' file2 file1

also with printf

awk...
4,039
Posted By rdcwayx
How about it? awk...
How about it?
awk '{sub(/\$/,"",$2)}/paid/{a[$1]+=$2}/due/{a[$1]-=$2}
END{for (i in a) printf "%s balance:$%.2f \n",i,a[i]}' infile

CoCo balance:$5.40
Euda balance:$45.00
Showing results 1 to 7 of 7

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