#! /bin/sh while read path do user=`echo $path | sed -e 's#^\(.*/var/alternc/html/\)\?[a-z0-9]/\([^/]*\)/.*$#\2#'` email=`mysql --defaults-file=/etc/mysql/alternc.cnf -B -N -e "SELECT mail FROM membres WHERE login=\"$user\";"` printf "$path\t$email\n" done