The above input should be converted as follows
213.64.56.208 6
213.46.27.204 60
The comparison should be done only with the first field (ip address). the summation of second field should be presented as the second field in the result. If this cannot be done with "uniq" command. Please let me know other ways to do the same.
Why not awk? It can be done in nearly any language, of course, but:
1) awk is especially good and efficient for this particular problem
2) everyone has an awk of some sort
Doing the same problem in generic sh, for instance:
...and it only works if the data's all in order. If it's not, you need to do
13 lines, n+1 extra processes, a sort operation, and a temp file for something awk handles natively and faster, in one compact line.
Would it help if the awk code were better explained?
Last edited by Corona688; 09-21-2011 at 06:41 PM..
Platform :Oracle Linux 6.4
Shell : bash
The below file has 7 lines , some of them are duplicates. There are only 3 distinct lines. But why is the uniq command still showing 7 ?
I just want the distinct lines to be returned.
$ cat test.txt
SELECT FC.COORD_SET_ID FROM OM_ORDER_FLOW F, -... (2 Replies)
Hi all,
I am trying to write a code for addition of n numbers which will be passed by the user as command line arguments.
I wrote the following code.
add=0
for (( i = 1 ; i <= $# ; i++ ))
do
add=`expr $i + $add`
done
#echo "sum is : $add"
input :
$./add.sh 12 32 14... (7 Replies)
Hello
i have tried to retrieve a distinct list of data from a file with a command combination but the uniq command line is not filtering the fields repeated.
Can someone help me ?
here is the file input
3837734|LAUNCH TEST01
3837735|LAUNCH TEST01
3837736|LAUNCH TEST01
3837737|LAUNCH... (4 Replies)
Hi ,
Can You Please let Know How use unix uniq command on a single column for deleting records from file
with Below Structure.Pipe Delimter File .
Source
Name | Account_Id
A | 101
B... (2 Replies)
Hello, I have a file with a list of car makes and specific information for each make. An example is:
@Audi:Warranty
@Audi:Pricing
@Audi:Colors
@Acura:Warranty
@Acura:Pricing
@Acura:Colors
and so on through a bunch of makes. I need to make a list in a selection box of just one name of... (12 Replies)