2017-10-04 2 views
1

이 인스턴스에서 inotifywait의 결과를 캡처하여 미칠 수 있습니다. 당신이 당신의 출력에 여분의 물건을 할 필요가 있다면 당신이 말할 수bash에서 inotifywait의 출력을 캡처합니다.

while inotifywait <whaveter> >> sync.log 
do 
    # Nothing 
done 

:

while inotifywait -q -e create,delete --format '%T %:e "%f"' --timefmt '%d/%m/%y %H:%M' "$DIR" 
    do 
     echo -e "$line" >> /mnt/pidrive1/Digital_Signage/log/"$hostname"_sync.log 
     echo -e "Folder contents:" $file_number "files in total: " $folder_list >> /mnt/pidrive1/Digital_Signage/log/"$hostname"_sync.log 
    done 
+0

여기에서 효과가없는 것은 무엇입니까? – Inian

+0

파일에서 $ @을 캡처하지 않습니다. – Ossama

답변

2

훨씬 간단한 방법은 당신이 될 것 원하는 것을 달성하기 : 여기

내 코드입니다

while out=$(inotifywait <whaveter>) 
do 
    # Stuff 
    # Just use $out normally 
done 
+0

while 루프에 더 많은 코드를 삽입하고 싶습니다. 코드를 수정하지 마십시오. 편집 된 코드를 참조하십시오. – Ossama

+0

@Ossama 캡처 할 수있는 버전을 추가했습니다. 산출. – cnicutar