0

I have two Files (.csv) say File1.csv and File2.csv with 'INVALID' records, generated at the end of a Informatica Job.

I am using below command to search for the file names 'INVALID', and then if either of the file has 'INVALID' records I have to mail that particular file and if both has invalid records, both the files has to be mailed to the user.

$ grep -il "invalid" File1.csv File2.csv | xargs -I'{}' uuencode {} | mailx -s"files" mymail@gmail.com

I am getting mail with two files attached but with no records.

I also tried using -a to attach the file:

$ grep -il "invalid" File1.csv File2.csv | xargs -I'{}' mailx -s"files" -a {} mymail@gmail.com

But the above command is throwing error:

mailx: illegal option -- a
Usage: mailx -eiIUdFntBNHvV~ -T FILE -u USER -h hops -r address
             -s SUBJECT -f FILE users
Toon Krijthe
  • 52,876
  • 38
  • 145
  • 202

1 Answers1

0

I think the options in grep is where you are going wrong. The "l" (Small L) option is for printing filenames and not contents of file, based on grep man:

  -l, --files-with-matches
      Suppress normal output; instead print the  name  of  each  input
      file  from  which  output would normally have been printed.  The
      scanning will stop on the first match.

So if you just remove the "-l" from first command, I think it will email you content of the file which is what you need, so command like:

$ grep -il "invalid" File1.csv File2.csv | xargs -I'{}' uuencode {} | mailx -s"files" mymail@gmail.com
Vishal Biyani
  • 4,297
  • 28
  • 55