Re: help!

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



On 03/24/2010 04: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 mail@xxxxxxxxxx -u Test email- disregard it  -f othermail@xxxxxxxxxxxxx -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 MAIL@xxxxxxxxxx
> 2. the date command gives the hour as well which is a bit annoying
>
>
> 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
>

How about:

for i in *.csv
do
HOURS=`cat $i | cut -d, -f2`
USER=`cat $i | cut -d, -f<user name field>`
DATE=`date <plus formatting options>`
echo "Dear $USER, This email...for week of $DATE is: $HOURS ..."
done

The <text> portions are bits you will need to change for your environment.
You can also put this in a file and script it instead of having to type 
it out every time.
To be more specific we would need to know if there is just one .csv file 
or one file per user and the format of each line.

John


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

[Index of Archives]     [CentOS]     [CentOS Announce]     [CentOS Development]     [CentOS ARM Devel]     [CentOS Docs]     [CentOS Virtualization]     [Carrier Grade Linux]     [Linux Media]     [Asterisk]     [DCCP]     [Netdev]     [Xorg]     [Linux USB]
  Powered by Linux