-3

I trying to control that my file exist or not in directory using if-elif-else statement in for loop. But in if and elif command line gives me this error: No command

Below is an example of the codes:

#! /bin/bash
controlfile="String"
firstfile="String"
lastfile="String"
nsolve=false
for i in $(ls $file1| grep /*.png)
do
    firstfile=${i:0:21} #satır 10
    if ["$firstfile"!="$file2"]; then  #ERROR LINE
                #something doing...
                nsolve=false
        for j in $(ls $file2| grep /*.jpeg)
        do
            if [${j:0:31}==${controlfile:0:31}]; then #.if already jpeg file exist like png
                nsolve=true
                continue 
            else 
                nsolve=false        
            fi
        done
    elif [$nsolve==true]  #ERROR LINE
    then
        #something doing...
        continue    
    fi
    lastfile=${i:0:21}
done
printf "%s\n" "Successfully"
SAFAK
  • 59
  • 8
  • 2
    Use http://shellcheck.net to fix the more obvious problems with your code before asking here. – chepner Jul 15 '19 at 18:03

1 Answers1

0

You are missing spaces around [ and ].

Mateusz Piotrowski
  • 8,029
  • 10
  • 53
  • 79