On 3/24/2010 3:48 AM, Roland RoLaNd wrote:
>
> hello,
>
> i've just wrote the following :
>
> more ./*.csv | grep -i XXX | echo "Dear XXX, This email is for informative 
> purposes. Your total number of hours for the week of `date` is: `cut  -d, 
> -f2` hours  Kindly note that the average weekly working hours is : 40." | 
> /usr/sbin/sendEmail -t m...@domain.com -u Test email- disregard it  -f 
> otherm...@subdomain.com -s smtp.domain.com:25
>
> this looks in a csv file that exists in the same directory for XX and outputs 
> the field right next to it as you notice from : `cut  -d, -f2`
>
> It's working pretty fine for just one user, but i have to do the same for 432 
> person. and its obviously not as professional as it should be due to the 
> following reasons:
>
> 1. i have to fill the name for each person in place of XXX as well as their 
> m...@domain.com

You need to provide more information here.  Does each XXX have its own 
directory (like /home/user)?

cd /home
for USER in *
do
...
done

Or are the names all in one csv file in another field you can find on 
the same line as the hours?

while read LINE
do
USER=`cut -d, -f<name_field_number> $LINE`
...
done <file.csv



> 2. the date command gives the hour as well which is a bit annoying

date can give about any format you want with a +format option.

> can anyone guide me on how to proceed?
> as you notice im a bit of a newbie with bash  and im trying my best to 
> improve my one liners/scripts

Just remember the perl can do everything the shell can do and much more, 
so if you run into trouble you can always switch to perl.

-- 
   Les Mikesell
    lesmikes...@gmail.com


_______________________________________________
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos

Reply via email to