0

I'm facing an issue since yesterday, trying to search on the internet how to fix it... Without result.

There it is. This is my program :

OTHERDIR="/tech/gtr/scripts/osm/scan-configs"
filename="IDF-952584-SW1-126.110.84.253"
estdifferent=true;
if $estdifferent ; then 
    x=0;
    for fic in `find $OTHERDIR/liste/ -type f -name $filename*` ; do
    {
    echo $fic
    if [[$fic == *bak*]] 
    then
            filename_tab[x]=$fic
            ((x++))
    fi
    }

I want to check if $fic contains * bak * at the end

But the debug show me this when it arrives at the "if" instruction :

'[[/tech/gtr/scripts/osm/scan-configs/liste/IDF-952584-SW1-126.110.84.253_bak1' == '*bak*]]'

comparatif.sh: line 29: [[/tech/gtr/scripts/osm/scan-configs/liste/IDF-952584-SW1-126.110.84.253_bak1: No such file or directory

Why is it telling me "no such file or directory" ? I'm comparing a var and a regex. (Line 29 is the IF $fic == * bak * instruction)

Gui O
  • 363
  • 4
  • 8
  • 22

1 Answers1

4

You need spaces inside the comparison:

if [[ $fic == *bak* ]] 
     ^             ^

Instead of

if [[$fic == *bak*]] 
fedorqui
  • 275,237
  • 103
  • 548
  • 598
  • Thanks for it. I've another problem with this code. If i add echo "somethin" under the loop The program is running the "for" loop for all the code, even the echo. is my syntax wrong ? – Gui O Jan 23 '14 at 13:22
  • A `for` loop is executed from a `do` up to a `done`, so no need to `{`, just use that syntax. If you want further explanation, please update your question with current code. – fedorqui Jan 23 '14 at 13:25
  • 1
    Yup, i read the entire code, i had a "done" token useless. Thanks – Gui O Jan 23 '14 at 13:31