startdate="2012_07_04-16:14:4"
path1="/home/drdos/sample"
days=0
find $path1 -name "*$startdate*" > teste.txt
while [ ${cat teste.txt | grep -c $startdate } -lt 0]
do
find $path1 -name "*.zip" ctime $days > teste.txt
days=`expr $days + 1`
done
echo " Files that are near the string u search are on teste.txt"
Hi to everyone, i have one question why i get 0 results if i define the variable $startdate="2012_07_04-16:14:45", and if i define it like this $startdate="2012_07_04-16:14:4", he returns the last modified file closer to that search on the dir ?
Ignoring the command substitution syntax error of using braces, ${ ... } , instead of parenthesis, $( ... ) , that expression is never true. grep's count is always non-negative and you're testing for a negative.
sorry my bad, i have the parenthesis on my orignal code, it was my mistake but yes even with the () , it does not return the values when i put the second digit on the seconds in $startdate but if i make a search for only one of the 2 digits in seconds it works correctly .