@hanuman
There is little bug in your script ...
For example, if the input file is :
1.0.0.1
1.0.0.2
2.1.0.0
The result is :
1.0.0.log
1.0.0.1
1.0.0.2
2.1.0.0
2.1.0.log
2.1.0.0
This is because, the pattern of the grep command is not anchored.
Code:
for i in ` sed 's/\./#/3' temp | cut -f 1 -d "#" | sort | uniq `
do
grep "^$i" temp >> $i.log ;
done ;
You can also use '$i." for the grep pattern.