Esto te servirá, si entendí tu pregunta.
for g in $master_ext_name_ddn; do
$VALOR=$(grep "$ruta" K?????$MES_ANTERIOR.rep | grep "$h")
if [ "$VALOR" == "" ]
then
echo "no hay match"
else
echo "Match!"
fi
done
Esto te servirá, si entendí tu pregunta.
for g in $master_ext_name_ddn; do
$VALOR=$(grep "$ruta" K?????$MES_ANTERIOR.rep | grep "$h")
if [ "$VALOR" == "" ]
then
echo "no hay match"
else
echo "Match!"
fi
done