Arithmatic operation
am 03.12.2007 17:54:20 von Nikunj
hello ,
i have a file called abc.txt , contain of this file is
# more abc.txt
1
2
34
45
65
.......
Now i want to take one value and perform arithmatic operation for that
i have created following script but its not working , i'm using ksh
#script1
FIX=1024
for i in `cat abc.txt`
do
length1=`expr $i / 2`
length2=`expr $length1 / $FIX`
length3=`expr $length2 / $FIX`
done >> op
would be appricate to help me out to resolve the problem also suggest
me the short and sweet way of this script ,if any one having idea.
i am converting values in GB
thanks
Nikunj
Re: Arithmatic operation
am 03.12.2007 18:10:19 von Ed Morton
On 12/3/2007 10:54 AM, Nikunj wrote:
> hello ,
>
> i have a file called abc.txt , contain of this file is
> # more abc.txt
> 1
> 2
> 34
> 45
> 65
> ......
> Now i want to take one value and perform arithmatic operation for that
> i have created following script but its not working , i'm using ksh
>
> #script1
> FIX=1024
> for i in `cat abc.txt`
> do
> length1=`expr $i / 2`
> length2=`expr $length1 / $FIX`
> length3=`expr $length2 / $FIX`
> done >> op
>
> would be appricate to help me out to resolve the problem also suggest
> me the short and sweet way of this script ,if any one having idea.
> i am converting values in GB
>
> thanks
>
> Nikunj
You don't show what you want the output to be. If it's just the final result of
the arithmetic ops, then all you need is:
awk 'BEGIN{fix=1024;div=2*fix*fix} {print $0 / div}' abc.txt > op
Regards,
Ed.
Re: Arithmatic operation
am 03.12.2007 18:26:34 von Bill Marcum
On 2007-12-03, Nikunj wrote:
>
>
> hello ,
>
> i have a file called abc.txt , contain of this file is
> # more abc.txt
> 1
> 2
> 34
> 45
> 65
> ......
> Now i want to take one value and perform arithmatic operation for that
> i have created following script but its not working , i'm using ksh
>
> #script1
> FIX=1024
> for i in `cat abc.txt`
> do
> length1=`expr $i / 2`
> length2=`expr $length1 / $FIX`
> length3=`expr $length2 / $FIX`
> done >> op
>
You are just setting variables, not outputting them. Also, instead of
expr you could use the shell's built-in arithmetic:
length=$((i/2))
echo $length
If you want non-integer results, ksh93 and zsh have floating point
arithmetic, or you can use bc or awk.
Re: Arithmatic operation
am 03.12.2007 18:36:24 von Nikunj
On Dec 3, 11:10 am, Ed Morton wrote:
> On 12/3/2007 10:54 AM, Nikunj wrote:
>
>
>
>
>
> > hello ,
>
> > i have a file called abc.txt , contain of this file is
> > # more abc.txt
> > 1
> > 2
> > 34
> > 45
> > 65
> > ......
> > Now i want to take one value and perform arithmatic operation for that
> > i have created following script but its not working , i'm using ksh
>
> > #script1
> > FIX=1024
> > for i in `cat abc.txt`
> > do
> > length1=`expr $i / 2`
> > length2=`expr $length1 / $FIX`
> > length3=`expr $length2 / $FIX`
> > done >> op
>
> > would be appricate to help me out to resolve the problem also suggest
> > me the short and sweet way of this script ,if any one having idea.
> > i am converting values in GB
>
> > thanks
>
> > Nikunj
>
> You don't show what you want the output to be. If it's just the final result of
> the arithmetic ops, then all you need is:
>
> awk 'BEGIN{fix=1024;div=2*fix*fix} {print $0 / div}' abc.txt > op
>
> Regards,
>
> Ed.- Hide quoted text -
>
> - Show quoted text -
great ....!!!
its very easy way just got it in one line ..
excellent solution ..i have done with the script
thanks ......
Nikunj
Re: Arithmatic operation
am 03.12.2007 18:57:14 von Nikunj
On Dec 3, 11:10 am, Ed Morton wrote:
> On 12/3/2007 10:54 AM, Nikunj wrote:
>
>
>
>
>
> > hello ,
>
> > i have a file called abc.txt , contain of this file is
> > # more abc.txt
> > 1
> > 2
> > 34
> > 45
> > 65
> > ......
> > Now i want to take one value and perform arithmatic operation for that
> > i have created following script but its not working , i'm using ksh
>
> > #script1
> > FIX=1024
> > for i in `cat abc.txt`
> > do
> > length1=`expr $i / 2`
> > length2=`expr $length1 / $FIX`
> > length3=`expr $length2 / $FIX`
> > done >> op
>
> > would be appricate to help me out to resolve the problem also suggest
> > me the short and sweet way of this script ,if any one having idea.
> > i am converting values in GB
>
> > thanks
>
> > Nikunj
>
> You don't show what you want the output to be. If it's just the final result of
> the arithmetic ops, then all you need is:
>
> awk 'BEGIN{fix=1024;div=2*fix*fix} {print $0 / div}' abc.txt > op
>
> Regards,
>
> Ed.- Hide quoted text -
>
> - Show quoted text -
hey ed,
i got the output in format "15.9911"
i want only 2 dec.point or want in integrer format how can i do ?
Re: Arithmatic operation
am 03.12.2007 19:30:46 von wayne
Nikunj wrote:
> hello ,
>
> i have a file called abc.txt , contain of this file is
> # more abc.txt
> 1
> 2
> 34
> 45
> 65
> ......
> Now i want to take one value and perform arithmatic operation for that
> i have created following script but its not working , i'm using ksh
>
> #script1
> FIX=1024
> for i in `cat abc.txt`
> do
> length1=`expr $i / 2`
> length2=`expr $length1 / $FIX`
> length3=`expr $length2 / $FIX`
> done >> op
>
> would be appricate to help me out to resolve the problem also suggest
> me the short and sweet way of this script ,if any one having idea.
> i am converting values in GB
>
> thanks
>
> Nikunj
The ohnly thing wrong is that you never echo the result. Just add
echo $length3
before the "done" line.
-Wayne
Re: Arithmatic operation
am 03.12.2007 20:07:56 von Ed Morton
On 12/3/2007 11:57 AM, Nikunj wrote:
> On Dec 3, 11:10 am, Ed Morton wrote:
>
>>On 12/3/2007 10:54 AM, Nikunj wrote:
>>
>>
>>
>>
>>
>>
>>>hello ,
>>
>>>i have a file called abc.txt , contain of this file is
>>># more abc.txt
>>>1
>>>2
>>>34
>>>45
>>>65
>>>......
>>>Now i want to take one value and perform arithmatic operation for that
>>>i have created following script but its not working , i'm using ksh
>>
>>>#script1
>>>FIX=1024
>>>for i in `cat abc.txt`
>>>do
>>>length1=`expr $i / 2`
>>>length2=`expr $length1 / $FIX`
>>>length3=`expr $length2 / $FIX`
>>>done >> op
>>
>>>would be appricate to help me out to resolve the problem also suggest
>>>me the short and sweet way of this script ,if any one having idea.
>>>i am converting values in GB
>>
>>>thanks
>>
>>>Nikunj
>>
>>You don't show what you want the output to be. If it's just the final result of
>>the arithmetic ops, then all you need is:
>>
>>awk 'BEGIN{fix=1024;div=2*fix*fix} {print $0 / div}' abc.txt > op
>>
>>Regards,
>>
>> Ed.- Hide quoted text -
>>
>>- Show quoted text -
>
>
> hey ed,
>
> i got the output in format "15.9911"
> i want only 2 dec.point or want in integrer format how can i do ?
Something like:
printf "%d\n",$0 / div
printf takes all the normal formatting options you'd expect in C (if that helps).
Ed.
Re: Arithmatic operation
am 03.12.2007 20:26:20 von Nikunj
On Dec 3, 1:07 pm, Ed Morton wrote:
> On 12/3/2007 11:57 AM, Nikunj wrote:
>
>
>
>
>
> > On Dec 3, 11:10 am, Ed Morton wrote:
>
> >>On 12/3/2007 10:54 AM, Nikunj wrote:
>
> >>>hello ,
>
> >>>i have a file called abc.txt , contain of this file is
> >>># more abc.txt
> >>>1
> >>>2
> >>>34
> >>>45
> >>>65
> >>>......
> >>>Now i want to take one value and perform arithmatic operation for that
> >>>i have created following script but its not working , i'm using ksh
>
> >>>#script1
> >>>FIX=1024
> >>>for i in `cat abc.txt`
> >>>do
> >>>length1=`expr $i / 2`
> >>>length2=`expr $length1 / $FIX`
> >>>length3=`expr $length2 / $FIX`
> >>>done >> op
>
> >>>would be appricate to help me out to resolve the problem also suggest
> >>>me the short and sweet way of this script ,if any one having idea.
> >>>i am converting values in GB
>
> >>>thanks
>
> >>>Nikunj
>
> >>You don't show what you want the output to be. If it's just the final result of
> >>the arithmetic ops, then all you need is:
>
> >>awk 'BEGIN{fix=1024;div=2*fix*fix} {print $0 / div}' abc.txt > op
>
> >>Regards,
>
> >> Ed.- Hide quoted text -
>
> >>- Show quoted text -
>
> > hey ed,
>
> > i got the output in format "15.9911"
> > i want only 2 dec.point or want in integrer format how can i do ?
>
> Something like:
>
> printf "%d\n",$0 / div
>
> printf takes all the normal formatting options you'd expect in C (if that helps).
>
> Ed.- Hide quoted text -
>
> - Show quoted text -
thanks for respond...
where i put it ?
before awk statement or after awk /
Nikunj
Re: Arithmatic operation
am 03.12.2007 20:29:08 von Ed Morton
On 12/3/2007 1:26 PM, Nikunj wrote:
> On Dec 3, 1:07 pm, Ed Morton wrote:
>
>>On 12/3/2007 11:57 AM, Nikunj wrote:
>>
>>
>>
>>
>>
>>
>>>On Dec 3, 11:10 am, Ed Morton wrote:
>>
>>>>On 12/3/2007 10:54 AM, Nikunj wrote:
>>>
>>>>>hello ,
>>>>
>>>>>i have a file called abc.txt , contain of this file is
>>>>># more abc.txt
>>>>>1
>>>>>2
>>>>>34
>>>>>45
>>>>>65
>>>>>......
>>>>>Now i want to take one value and perform arithmatic operation for that
>>>>>i have created following script but its not working , i'm using ksh
>>>>
>>>>>#script1
>>>>>FIX=1024
>>>>>for i in `cat abc.txt`
>>>>>do
>>>>>length1=`expr $i / 2`
>>>>>length2=`expr $length1 / $FIX`
>>>>>length3=`expr $length2 / $FIX`
>>>>>done >> op
>>>>
>>>>>would be appricate to help me out to resolve the problem also suggest
>>>>>me the short and sweet way of this script ,if any one having idea.
>>>>>i am converting values in GB
>>>>
>>>>>thanks
>>>>
>>>>>Nikunj
>>>>
>>>>You don't show what you want the output to be. If it's just the final result of
>>>>the arithmetic ops, then all you need is:
>>>
>>>>awk 'BEGIN{fix=1024;div=2*fix*fix} {print $0 / div}' abc.txt > op
>>>
>>>>Regards,
>>>
>>>> Ed.- Hide quoted text -
>>>
>>>>- Show quoted text -
>>>
>>>hey ed,
>>
>>>i got the output in format "15.9911"
>>>i want only 2 dec.point or want in integrer format how can i do ?
>>
>>Something like:
>>
>> printf "%d\n",$0 / div
>>
>>printf takes all the normal formatting options you'd expect in C (if that helps).
>>
>> Ed.- Hide quoted text -
>>
>>- Show quoted text -
>
>
> thanks for respond...
>
> where i put it ?
>
> before awk statement or after awk /
awk 'BEGIN{fix=1024;div=2*fix*fix} {printf "%d\n",$0 / div}' abc.txt > op
Re: Arithmatic operation
am 03.12.2007 20:42:18 von Nikunj
On Dec 3, 1:29 pm, Ed Morton wrote:
> On 12/3/2007 1:26 PM, Nikunj wrote:
>
>
>
>
>
> > On Dec 3, 1:07 pm, Ed Morton wrote:
>
> >>On 12/3/2007 11:57 AM, Nikunj wrote:
>
> >>>On Dec 3, 11:10 am, Ed Morton wrote:
>
> >>>>On 12/3/2007 10:54 AM, Nikunj wrote:
>
> >>>>>hello ,
>
> >>>>>i have a file called abc.txt , contain of this file is
> >>>>># more abc.txt
> >>>>>1
> >>>>>2
> >>>>>34
> >>>>>45
> >>>>>65
> >>>>>......
> >>>>>Now i want to take one value and perform arithmatic operation for that
> >>>>>i have created following script but its not working , i'm using ksh
>
> >>>>>#script1
> >>>>>FIX=1024
> >>>>>for i in `cat abc.txt`
> >>>>>do
> >>>>>length1=`expr $i / 2`
> >>>>>length2=`expr $length1 / $FIX`
> >>>>>length3=`expr $length2 / $FIX`
> >>>>>done >> op
>
> >>>>>would be appricate to help me out to resolve the problem also suggest
> >>>>>me the short and sweet way of this script ,if any one having idea.
> >>>>>i am converting values in GB
>
> >>>>>thanks
>
> >>>>>Nikunj
>
> >>>>You don't show what you want the output to be. If it's just the final result of
> >>>>the arithmetic ops, then all you need is:
>
> >>>>awk 'BEGIN{fix=1024;div=2*fix*fix} {print $0 / div}' abc.txt > op
>
> >>>>Regards,
>
> >>>> Ed.- Hide quoted text -
>
> >>>>- Show quoted text -
>
> >>>hey ed,
>
> >>>i got the output in format "15.9911"
> >>>i want only 2 dec.point or want in integrer format how can i do ?
>
> >>Something like:
>
> >> printf "%d\n",$0 / div
>
> >>printf takes all the normal formatting options you'd expect in C (if that helps).
>
> >> Ed.- Hide quoted text -
>
> >>- Show quoted text -
>
> > thanks for respond...
>
> > where i put it ?
>
> > before awk statement or after awk /
>
> awk 'BEGIN{fix=1024;div=2*fix*fix} {printf "%d\n",$0 / div}' abc.txt > op- Hide quoted text -
>
> - Show quoted text -
thanks for your prompt response , i've done with it...!!!
reg,
nik
Re: Arithmatic operation
am 04.12.2007 18:27:03 von Nikunj
On Dec 3, 1:42 pm, Nikunj wrote:
> On Dec 3, 1:29 pm, Ed Morton wrote:
>
>
>
>
>
> > On 12/3/2007 1:26 PM, Nikunj wrote:
>
> > > On Dec 3, 1:07 pm, Ed Morton wrote:
>
> > >>On 12/3/2007 11:57 AM, Nikunj wrote:
>
> > >>>On Dec 3, 11:10 am, Ed Morton wrote:
>
> > >>>>On 12/3/2007 10:54 AM, Nikunj wrote:
>
> > >>>>>hello ,
>
> > >>>>>i have a file called abc.txt , contain of this file is
> > >>>>># more abc.txt
> > >>>>>1
> > >>>>>2
> > >>>>>34
> > >>>>>45
> > >>>>>65
> > >>>>>......
> > >>>>>Now i want to take one value and perform arithmatic operation for that
> > >>>>>i have created following script but its not working , i'm using ksh
>
> > >>>>>#script1
> > >>>>>FIX=1024
> > >>>>>for i in `cat abc.txt`
> > >>>>>do
> > >>>>>length1=`expr $i / 2`
> > >>>>>length2=`expr $length1 / $FIX`
> > >>>>>length3=`expr $length2 / $FIX`
> > >>>>>done >> op
>
> > >>>>>would be appricate to help me out to resolve the problem also suggest
> > >>>>>me the short and sweet way of this script ,if any one having idea.
> > >>>>>i am converting values in GB
>
> > >>>>>thanks
>
> > >>>>>Nikunj
>
> > >>>>You don't show what you want the output to be. If it's just the final result of
> > >>>>the arithmetic ops, then all you need is:
>
> > >>>>awk 'BEGIN{fix=1024;div=2*fix*fix} {print $0 / div}' abc.txt > op
>
> > >>>>Regards,
>
> > >>>> Ed.- Hide quoted text -
>
> > >>>>- Show quoted text -
>
> > >>>hey ed,
>
> > >>>i got the output in format "15.9911"
> > >>>i want only 2 dec.point or want in integrer format how can i do ?
>
> > >>Something like:
>
> > >> printf "%d\n",$0 / div
>
> > >>printf takes all the normal formatting options you'd expect in C (if that helps).
>
> > >> Ed.- Hide quoted text -
>
> > >>- Show quoted text -
>
> > > thanks for respond...
>
> > > where i put it ?
>
> > > before awk statement or after awk /
>
> > awk 'BEGIN{fix=1024;div=2*fix*fix} {printf "%d\n",$0 / div}' abc.txt > op- Hide quoted text -
>
> > - Show quoted text -
>
> thanks for your prompt response , i've done with it...!!!
>
> reg,
> nik- Hide quoted text -
>
> - Show quoted text -
hello ,
thanks all for response
hello i got the output in following format i got dg name twice for
example dg_te1's having 2 output 11 &39 . i want to make it as one
mean i want it dg_te1 50 mean (11+39) . can i do it ...
your help would be appriciated.
dg_te1_Data 14
dg_te1_Data 0
dg_te1 15
dg_te1 11
dg_te1 39
dg_te1 39
Thanks
niks
Re: Arithmatic operation
am 04.12.2007 18:33:16 von Ed Morton
On 12/4/2007 11:27 AM, Nikunj wrote:
> On Dec 3, 1:42 pm, Nikunj wrote:
>
>>On Dec 3, 1:29 pm, Ed Morton wrote:
>>
>>
>>
>>
>>
>>
>>>On 12/3/2007 1:26 PM, Nikunj wrote:
>>
>>>>On Dec 3, 1:07 pm, Ed Morton wrote:
>>>
>>>>>On 12/3/2007 11:57 AM, Nikunj wrote:
>>>>
>>>>>>On Dec 3, 11:10 am, Ed Morton wrote:
>>>>>
>>>>>>>On 12/3/2007 10:54 AM, Nikunj wrote:
>>>>>>
>>>>>>>>hello ,
>>>>>>>
>>>>>>>>i have a file called abc.txt , contain of this file is
>>>>>>>># more abc.txt
>>>>>>>>1
>>>>>>>>2
>>>>>>>>34
>>>>>>>>45
>>>>>>>>65
>>>>>>>>......
>>>>>>>>Now i want to take one value and perform arithmatic operation for that
>>>>>>>>i have created following script but its not working , i'm using ksh
>>>>>>>
>>>>>>>>#script1
>>>>>>>>FIX=1024
>>>>>>>>for i in `cat abc.txt`
>>>>>>>>do
>>>>>>>>length1=`expr $i / 2`
>>>>>>>>length2=`expr $length1 / $FIX`
>>>>>>>>length3=`expr $length2 / $FIX`
>>>>>>>>done >> op
>>>>>>>
>>>>>>>>would be appricate to help me out to resolve the problem also suggest
>>>>>>>>me the short and sweet way of this script ,if any one having idea.
>>>>>>>>i am converting values in GB
>>>>>>>
>>>>>>>>thanks
>>>>>>>
>>>>>>>>Nikunj
>>>>>>>
>>>>>>>You don't show what you want the output to be. If it's just the final result of
>>>>>>>the arithmetic ops, then all you need is:
>>>>>>
>>>>>>>awk 'BEGIN{fix=1024;div=2*fix*fix} {print $0 / div}' abc.txt > op
>>>>>>
>>>>>>>Regards,
>>>>>>
>>>>>>> Ed.- Hide quoted text -
>>>>>>
>>>>>>>- Show quoted text -
>>>>>>
>>>>>>hey ed,
>>>>>
>>>>>>i got the output in format "15.9911"
>>>>>>i want only 2 dec.point or want in integrer format how can i do ?
>>>>>
>>>>>Something like:
>>>>
>>>>> printf "%d\n",$0 / div
>>>>
>>>>>printf takes all the normal formatting options you'd expect in C (if that helps).
>>>>
>>>>> Ed.- Hide quoted text -
>>>>
>>>>>- Show quoted text -
>>>>
>>>>thanks for respond...
>>>
>>>>where i put it ?
>>>
>>>>before awk statement or after awk /
>>>
>>>awk 'BEGIN{fix=1024;div=2*fix*fix} {printf "%d\n",$0 / div}' abc.txt > op- Hide quoted text -
>>
>>>- Show quoted text -
>>
>>thanks for your prompt response , i've done with it...!!!
>>
>>reg,
>>nik- Hide quoted text -
>>
>>- Show quoted text -
>
>
> hello ,
>
> thanks all for response
>
>
> hello i got the output in following format i got dg name twice for
> example dg_te1's having 2 output 11 &39 . i want to make it as one
> mean i want it dg_te1 50 mean (11+39) . can i do it ...
> your help would be appriciated.
>
>
> dg_te1_Data 14
>
> dg_te1_Data 0
>
> dg_te1 15
>
> dg_te1 11
>
> dg_te1 39
>
> dg_te1 39
>
> Thanks
> niks
The output you posted doesn't match the input you posted or the script I gave
you and it sounds like your requirements have changed. Start again. Tell us what
you want to do, post sample input, expected output, the script you ran, the
output it gives, and what's wrong with that output.
Ed.
Re: Arithmatic operation
am 04.12.2007 21:24:27 von Nikunj
On Dec 4, 11:33 am, Ed Morton wrote:
> On 12/4/2007 11:27 AM, Nikunj wrote:
>
>
>
>
>
> > On Dec 3, 1:42 pm, Nikunj wrote:
>
> >>On Dec 3, 1:29 pm, Ed Morton wrote:
>
> >>>On 12/3/2007 1:26 PM, Nikunj wrote:
>
> >>>>On Dec 3, 1:07 pm, Ed Morton wrote:
>
> >>>>>On 12/3/2007 11:57 AM, Nikunj wrote:
>
> >>>>>>On Dec 3, 11:10 am, Ed Morton wrote:
>
> >>>>>>>On 12/3/2007 10:54 AM, Nikunj wrote:
>
> >>>>>>>>hello ,
>
> >>>>>>>>i have a file called abc.txt , contain of this file is
> >>>>>>>># more abc.txt
> >>>>>>>>1
> >>>>>>>>2
> >>>>>>>>34
> >>>>>>>>45
> >>>>>>>>65
> >>>>>>>>......
> >>>>>>>>Now i want to take one value and perform arithmatic operation for that
> >>>>>>>>i have created following script but its not working , i'm using ksh
>
> >>>>>>>>#script1
> >>>>>>>>FIX=1024
> >>>>>>>>for i in `cat abc.txt`
> >>>>>>>>do
> >>>>>>>>length1=`expr $i / 2`
> >>>>>>>>length2=`expr $length1 / $FIX`
> >>>>>>>>length3=`expr $length2 / $FIX`
> >>>>>>>>done >> op
>
> >>>>>>>>would be appricate to help me out to resolve the problem also suggest
> >>>>>>>>me the short and sweet way of this script ,if any one having idea.
> >>>>>>>>i am converting values in GB
>
> >>>>>>>>thanks
>
> >>>>>>>>Nikunj
>
> >>>>>>>You don't show what you want the output to be. If it's just the final result of
> >>>>>>>the arithmetic ops, then all you need is:
>
> >>>>>>>awk 'BEGIN{fix=1024;div=2*fix*fix} {print $0 / div}' abc.txt > op
>
> >>>>>>>Regards,
>
> >>>>>>> Ed.- Hide quoted text -
>
> >>>>>>>- Show quoted text -
>
> >>>>>>hey ed,
>
> >>>>>>i got the output in format "15.9911"
> >>>>>>i want only 2 dec.point or want in integrer format how can i do ?
>
> >>>>>Something like:
>
> >>>>> printf "%d\n",$0 / div
>
> >>>>>printf takes all the normal formatting options you'd expect in C (if that helps).
>
> >>>>> Ed.- Hide quoted text -
>
> >>>>>- Show quoted text -
>
> >>>>thanks for respond...
>
> >>>>where i put it ?
>
> >>>>before awk statement or after awk /
>
> >>>awk 'BEGIN{fix=1024;div=2*fix*fix} {printf "%d\n",$0 / div}' abc.txt > op- Hide quoted text -
>
> >>>- Show quoted text -
>
> >>thanks for your prompt response , i've done with it...!!!
>
> >>reg,
> >>nik- Hide quoted text -
>
> >>- Show quoted text -
>
> > hello ,
>
> > thanks all for response
>
> > hello i got the output in following format i got dg name twice for
> > example dg_te1's having 2 output 11 &39 . i want to make it as one
> > mean i want it dg_te1 50 mean (11+39) . can i do it ...
> > your help would be appriciated.
>
> > dg_te1_Data 14
>
> > dg_te1_Data 0
>
> > dg_te1 15
>
> > dg_te1 11
>
> > dg_te1 39
>
> > dg_te1 39
>
> > Thanks
> > niks
>
> The output you posted doesn't match the input you posted or the script I gave
> you and it sounds like your requirements have changed. Start again. Tell us what
> you want to do, post sample input, expected output, the script you ran, the
> output it gives, and what's wrong with that output.
>
> Ed.- Hide quoted text -
>
> - Show quoted text -
ed,
it gives me list me twice output of the first columnfor example
dg_te1 is twice i want it in single and want to add the both
values which generated by the dg_te1 here in case its 11+15 .. .so it
become ease of my work....thanks
Re: Arithmatic operation
am 04.12.2007 21:49:04 von Ed Morton
On 12/4/2007 2:24 PM, Nikunj wrote:
> On Dec 4, 11:33 am, Ed Morton wrote:
>
>>On 12/4/2007 11:27 AM, Nikunj wrote:
>>>hello i got the output in following format i got dg name twice for
>>>example dg_te1's having 2 output 11 &39 . i want to make it as one
>>>mean i want it dg_te1 50 mean (11+39) . can i do it ...
>>>your help would be appriciated.
>>
>>>dg_te1_Data 14
>>
>>>dg_te1_Data 0
>>
>>>dg_te1 15
>>
>>>dg_te1 11
>>
>>>dg_te1 39
>>
>>>dg_te1 39
>>
>>>Thanks
>>>niks
>>
>>The output you posted doesn't match the input you posted or the script I gave
>>you and it sounds like your requirements have changed. Start again. Tell us what
>>you want to do, post sample input, expected output, the script you ran, the
>>output it gives, and what's wrong with that output.
>>
>> Ed.- Hide quoted text -
>>
>>- Show quoted text -
>
>
> ed,
>
> it gives me list me twice output of the first columnfor example
> dg_te1 is twice i want it in single and want to add the both
> values which generated by the dg_te1 here in case its 11+15 .. .so it
> become ease of my work....thanks
Here's the input file you posted:
> i have a file called abc.txt , contain of this file is
> # more abc.txt
> 1
> 2
> 34
> 45
> 65
> ......
where all this dg_tel stuff is coming from is a mystery. Seriously - do what I
suggested about starting over.
Ed.
Re: Arithmatic operation
am 04.12.2007 21:51:16 von Bill Marcum
On 2007-12-04, Nikunj wrote:
>
>
>
> it gives me list me twice output of the first columnfor example
> dg_te1 is twice i want it in single and want to add the both
> values which generated by the dg_te1 here in case its 11+15 .. .so it
> become ease of my work....thanks
awk '{sum[$1]+=$2} END{for(x in sum) print x,xum[x]}'
Re: Arithmatic operation
am 04.12.2007 23:07:27 von Ed Morton
On 12/4/2007 2:51 PM, Bill Marcum wrote:
> On 2007-12-04, Nikunj wrote:
>
>>
>>
>>it gives me list me twice output of the first columnfor example
>>dg_te1 is twice i want it in single and want to add the both
>>values which generated by the dg_te1 here in case its 11+15 .. .so it
>>become ease of my work....thanks
>
>
> awk '{sum[$1]+=$2} END{for(x in sum) print x,xum[x]}'
That won't do it. In the part you snipped, he said this:
> hello i got the output in following format i got dg name twice for
> example dg_te1's having 2 output 11 &39 . i want to make it as one
> mean i want it dg_te1 50 mean (11+39) . can i do it ...
> your help would be appriciated.
>
>
> dg_te1_Data 14
>
> dg_te1_Data 0
>
> dg_te1 15
>
> dg_te1 11
>
> dg_te1 39
>
> dg_te1 39
so assuming he has an input file with a format similair to that, then your
script would produce a total of 104 for the "dg_tel" records whereas the OP says
it should be 50. There's something he's not telling us....
Ed.