Cannot find Error

Today is my first day in shell scripting.
I am not able to find error.
Need Help!

Error is :-
syntax error near unexpected token `then'
test.sh: line 50: ` if[-n "$patha"]; then

echo "Enter Path o(if empty file will be unzipped to /var/www/):"             read path              
echo "Enter Old domain name(default is local.cms.com):"             
read old              

if[-n "$path"];    then                         ======>Error in this line.
         if [ -n "$old" ]; then                     
           grep -r "$old" "$path"                     
            echo "Enter New domain name:"
           read new                     
           if [ -n "$new" ]; then 
               grep -rl "$old" "$path" | xargs sed -i "s/$old/$new/g" 
           else 
             echo "Cannot be empty"                                                  
          fi                   
         else                     
            old="local.cms.com"                     
              grep -r "$old" "$path"                     
           echo "Enter New domain name:"                     
            read new                         
              if [ -n "$new" ]; then                             
grep -rl "$old" "$path" | xargs sed -i "s/$old/$new/g"                         
else 
    echo "Cannot be empty"                                                          
fi                  
fi              
  else                 
   echo "Invalid Path"             
fi

Add a space after '[' and before ']' like:

if [ -n "$path" ]

instead of:

if[-n "$path"]
1 Like

try giving proper spaces after

if 

statement

1 Like

Thanks Both Of You :slight_smile:

---------- Post updated at 06:32 AM ---------- Previous update was at 06:30 AM ----------

Thanks