2012-09-26 4 views
0

File1.csvFile2.csv'INVALID' 개의 두 개의 파일 (.csv) 레코드가 Informatica 작업 끝에 생성되었습니다.오류가있는 Unix를 사용하여 메일 발송 첨부 파일

나는 파일 이름 'INVALID'를 검색하는 명령 아래 사용하고, 다음 파일 중 하나가 'INVALID' 기록이있는 경우 그 특정 파일을 메일이 모두가 잘못 레코드가 모두있는 경우 파일이 우편으로 발송한다 사용자.

$ grep -il "invalid" File1.csv File2.csv | xargs -I'{}' uuencode {} | mailx -s"files" [email protected] 

두 개의 파일이 첨부되었지만 레코드가없는 메일이 전송됩니다.

는 또한 파일 첨부 -a를 사용하여 시도 :

$ grep -il "invalid" File1.csv File2.csv | xargs -I'{}' mailx -s"files" -a {} [email protected] 

을하지만, 위의 명령은 오류를 던지고있다 :

mailx: illegal option -- a 
Usage: mailx -eiIUdFntBNHvV~ -T FILE -u USER -h hops -r address 
      -s SUBJECT -f FILE users 

답변

0

난 당신이 잘못 갈 곳 grep의 옵션을 생각합니다. 은 "L"이 (작은 L)이 옵션은 그렙 사람에 따라, 파일의 내용을 인쇄 파일 이름입니다하지 : 당신은 단지 첫 번째 명령에서 "-l"를 제거한다면

-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. 

, 나는 이메일을 생각 당신은 당신이 필요로하는 파일의 내용입니다. 따라서 다음 명령을 입력하십시오 :

$ grep -il "invalid" File1.csv File2.csv | xargs -I'{}' uuencode {} | mailx -s"files" [email protected] 
관련 문제