2016-11-03 2 views
-1

사용하여 하나의 메일에 find 명령에서보다 30 분내가 발견 한 명령을 찾을 수 아래 사용하여 UNIX

find /pathA -type f -mmin -30 -print0 

있는 3 파일을 여러 개의 파일을 추가하지만 난 한 메일에있는 모든 3 개 개의 파일을 보내려면 첨부 파일 3 개가 있습니다. 아래 코드를 시도했습니다. 단일 파일에서는 작동하지만 다중 파일에서는 작동하지 않습니다. 도와주세요.

echo "hi" | mail -s "files older less than 30 min" -a "$(find /pathA -type f -mmin -30 -print0)" [email protected] 

답변

0

각 파일마다 별도의 -a 옵션을 추가해야합니다. 이것을 시도해보십시오 : 모든 메일 옵션을 담을 배열을 누적합니다 :

mail_opts=(-s "files older less than 30 min") 
while read -d "" -r file; do 
    mail_opts+=(-a "$file") 
done < <(find /pathA -type f -mmin -30 -print0) 
echo "message body" | mail "${mail_opts[@]}" [email protected] 
0

시도해 볼 수 있습니까?

find /pathA -type f -mmin -30 -exec bash -c 'uuencode {} {}' \; | mail -s "files older less than 30 min" [email protected] 
관련 문제