0
我是新手,因此這可能看起來像一個愚蠢的問題,但我不能讓這個代碼工作。看起來,grep正在尋找變量名稱而不是它的值。感謝任何幫助appriciated。grep將不能在bash腳本中工作
if [ "$file" == "osi_OpenInterest" ]
then
count=`cat timestamps.txt | grep "${file}" | grep "${currdate}" | grep "07:" | grep "AM" | wc -l`
if [ $count -eq 0 ];
then
echo "$file not found" | mail -s "RetrieverB Missing File" "$email"
fi
fi
以目前的形式回答這個問題是不可能的。哪部分你有問題? 'echo「X $ {file} X $ {currdate} X」;'拿出具體的例子,沒有變量,時間戳文件的內容和期望的輸出。 –
timestamps.txt包含:** 12-04-2012 07:30 AM 15028622 osi_OpenInterest ** 這就是grep語句的預期輸出,所以count應該是1.從我可以告訴greps似乎在執行搜索對於$ {file}而不是** osi_OpenInterest **同樣的事情與$ {currdate}應該在尋找** 12-04-2012 **而不是「$ {currdate} – user1877532
我要求您驗證您的內容變量。不要拿出瘋狂的假設(「它正在尋找$ {currdate}」) –