I am trying to create a basic MapReduce function in bash (I am very new at it). I have two scripts at the moment, job_master.sh and map_function.sh. I am trying to run the map function from the job master to cut from a data file, and if it doesn't exist send it to key, but if it does send it to the file of that name. Nothing is happening when I run the job_master script or the map_function script on its own with a file as an argument. It was working before I added the if statements into the map_function.
I have included both codes below if anyone is able to spot why they are not running. I tried including echo statements to test and it is not entering the loop in the job_master script, or doing anything at all in the map_function script.
MAP_FUNCTION
#!/bin/bash
while IFS="," read -r date prod remainder; do
if [ ! -e "$prod" ];
then
echo $prod >> keys
else
echo $prod >> $prod
fi
done
JOB_MASTER
#!/bin/bash
files=$(ls | egrep 'sales_a*')
for elem in $files ; do
./map_function.sh $elem
done