I tried making the hadoop streaming program of calculating characters using shell but it seems to be failing again and again. Please help. The following is the code:
Mapper.sh
#!/bin/bash
while read line
do
for i in echo $line | awk -F '' -v 'OFS=\n' '{$1=$1}1'
do
echo -e $i’\t’“1”
done
done
Reducer.sh
#!/bin/bash
i=1
lastkey="";
total=0;
while read line
do
newkey=echo $line | awk '{print $1}'
value=echo $line | awk '{print $2}'
if [ “$i” == “1” ]
then
lastkey=$newkey;
i=expr $i + 1
;
fi
if [[ “$lastkey” != “$newkey” ]]
then
echo -e “$lastkey\t$total”
total=0;
lastkey=$newkey;
i=0;
fi
total=expr $total + 1
;
lastkey=$newkey;
i=expr $i + 1
;
done