programming logic required
Guys,
I need some help here. I have a directory which has "x" no of files. For each file it has data separated by "," !!! wow !! that is nice , we got delimiter now that makes life easy !!! Now all what I want to do is any row(each row has 6 fields separated by ",") if it has 3 rd field as "abcdefgh" then I want to send that file as an attachment to user. I have implemented the logic but it seems it send emails(spam) but all i want is just one email with that file(sending with uuencode). Here is the code. Code:
cd $BASE_DIRECTORY |
probably «break» just after mailx?
|
@Ygrex
Thank you ! It did worked. Anything else cool stuff or smart thing we can do make script faster? or anything cool thing which you can think at this stage? |
I prefer using 'mpack':
Code:
#!/bin/sh -- |
grep -l <pattern> <filelist> will give you the name of those files, pattern will look like:
^[^,]*,[^,]*,abcdefgh, |
@unSpawn
Pretty down, shame we don't have mpack any other better alternative you can think of? |
unSpawn.
Impressed, I have never such a code before, can you explain every line of it?(f you don't mind?) |
sorry, I have no time to test it, but probably something like this:
Code:
grep -lR <pattern> "${BASE_DIRECTORY}" | xargs -n 1 send_mail |
Quote:
Quote:
Code:
# This is just a hedge as some tools tend to produce unexpected output if those environment variables are set differently: 1) Other common questions / problems: http://mywiki.wooledge.org/ParsingLs http://mywiki.wooledge.org/UsingFind http://mywiki.wooledge.org/Arguments http://mywiki.wooledge.org/WordSplitting http://mywiki.wooledge.org/Quotes |
@unSpawm.
How to do if I want to exit at the same time echo message and send it via email? means in addition to exit I want to echo some message and send some critical email. How to do? ---------- Post added 05-10-13 at 09:40 AM ---------- @unSpawn. :( Not installed on our box. |
thank you pan64 :)
|
Quote:
Code:
if [ "${CONDITION}" = "match_this_condition" ]; then |
Thank you unSpawn :)
|
All times are GMT -5. The time now is 02:34 PM. |