0

I have my loop for:

for i in 1.34*
do
if [ -f $i/rela/*log ] ; then
echo $i >> /tmp/allog
else
echo $i >> /tmp/alnolog
fi
done  

Is working well. We have different version of releases in ascending order. Often i need to create another file with all the version which don't have any log into the directory. The problem is when i have to create this file with a lot of version to insert.

I'd like to create a script and ask the first release with which I have to start and the last one(the normal format for the release is 1.34.0.04).

2 Answers 2

0

You might get away with simple shell patterns. E.g.

  • for i in 1.3[4-9]* 1.4[0-3]* matches revisions 1.34 to1.43`
  • for i in 1.34.0.0[4-9]* 1.34.0.[1-9]* 1.34.[1-2].0[1-5]* matches revisions 1.34.0.04 to 1.34.2.05

etc

4
  • I know, but my problem is create a loop for between the first release and the last one and take just what i need.
    – FaMontyN2
    Jun 4, 2015 at 9:56
  • if your existing script works, then there are files of the form 1.34.0.03 in the current directory, and my modifications to your loop should accomplish what you wanted
    – Anul
    Jun 4, 2015 at 10:04
  • I know what you mean, and i appreciate it. But i like do a loop for between two variables: echo "Enter The Release Which You Have to start with : \c" read START echo "Enter The Release Which You Have to finish with : \c" read END For i between START and END Is it clearer now?
    – FaMontyN2
    Jun 4, 2015 at 10:17
  • I think so... Let me add that you could read the patterns I described too (though I understand they are harder to type/think up then simple revision ranges)
    – Anul
    Jun 4, 2015 at 10:36
0

i've tried to create this script:

echo "Enter The Release Which You Have to start with : \c"
read START

echo "Enter The Release Which You Have to finish with : \c"
read END

cd ${RELDIR}
for i in $(eval echo "{$START..$END}")
do
if [ -f $i/rela/*log ] ; then
echo $i >> /tmp/allog
else
echo $i >> /tmp/alnolog
fi
done

But is not working because is stamp out just the two variables that i put.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.