2017-05-11 5 views
0

쉘 스크립트를 통해 디렉토리에 저장된 파일 그룹에서 특정 패턴을 grep하려고합니다. 그러나 스크립트는 파일을 스캔하지만 결과는 가져 오지 않습니다.grep이 쉘 스크립트에서 작동하지 않습니다.

find /home/arun/file_status -type f -name product_feed_stock_20170504*.out -exec grep finishing: No such file or directory 0 Hai

+0

아래는 오류가 찾기/홈/룬/file_status 타입 F -name product_feed_ * 제품 * _20170504 * 간부 그렙 마무리 .OUT : 해당 파일이나 디렉토리 하이 – Arun

답변

1

하기에 따옴표를 제거해야합니다 : 당신이 아래의

#!/bin/bash 
dt=$(date --d='7 day ago' +'%Y%m%d') 
countT=$("find /home/arun/file_status -type f -name "product_feed_*stock*_${dt}*.out" -exec grep "finishing with status COMPLETE" {} \;" | wc -l) 
echo $countT 
if [ $countT -eq 5 ] 
then 
    echo "Hello" 
else 
    echo "Hai" 
fi 

문제에 도움을 주시기 바랍니다 수 있습니다, 여기에 finishing with status COMPLETE

코드가 같은 패턴 (5 개) 파일이있는 것은 오류입니다 find 명령.

#!/bin/bash 

dt=$(date --d='7 day ago' +'%Y%m%d') 

countT=$(find /home/arun/file_status -type f -name "product_feed_stock_${dt}*.out" -exec grep "finishing with status COMPLETE" {} \;| wc -l) 

echo $countT 
if [ $countT -eq 5 ] 
then 
    echo "Hello" 
else 
    echo "Hai" 
fi 
+0

당신을 감사합니다 일한 – Arun