Mailing files with, ls filtered with grep

Hi guys

Im new to forum so please dont be hard to me if I make any mistakes :slight_smile:

I want to the following task:

  1. I have a file lets say file1, which contains job names with numbers which have failed to start and ....
    I can sort that file into another to get only the Job numbers with awk
    the file1 looks like this
    >cat file1
    O575757.*
    O262628.*

  2. I want to send also the whole log from the jobs that have failed in a attachement in a mail.
    want do to something like
    for i in `ls /log_path/date/ | !!! need to specify the grep so that i will give output of those files with the names from file1`
    then goes
    do
    uuencode $i $i
    done | mailx -s "Files" mymail@company.com

!!! Point is I dont know how to apply the pattern for ls do echo only the that match from the file1

I will appreciate any help

Thank you in advance

Hello in the mean time I have made some progress so this is how it should work

#!/usr/bin/ksh
set -x
homedir="/home/martin/test"
datum="2009.01.27"
premena=`cat ${homedir}/file1`
echo $premena
export homedir datum premena
(for file in `ls ${homedir}/${datum} | grep "$premena"`
do
uuencode "$file" "$file"
done) | mailx -s "subory" martin@localhost

dont know way but I have some errors also after that that I have installed shareutils for uuencode, getting an error uuencode fopen-ing

Has somethis problem, if yes did U manage to fix it?

not tested....

#!/usr/bin/ksh
set -x
homedir='/home/martin/test'
datum='2009.01.27'

   while read file
   do
      for i in ${homedir}/${datum}/${file}
      do
         (uuencode "$i" "$i" ) | mailx -s "subory" martin@localhost
      done
   done < ${homedir}/file1

Hi vgersh99

Thxs a lot its working now :b:, gonna try that out right this morning.

Can I ask why did it didnt worked my way?

Thank you again vgersh99
:smiley: