I have a shell script named 'teleport.sh' like this:if [ $1=1 ];    then    shift        mv $@ ~/lab/Sunelif [ $1=2 ];    then    shift        mv $@ ~/lab/Moonelif [ $1=3 ];    then    shift        mv $@ ~/lab/EarthfiWhen I execute:sh teleport.sh 2 testfileThis testfile is moved to the ~/lab/Sun directory, which confuses me a lot as I didn't pass 1 or '1' to that script.What's wrong here?
Why is the 'if [ $1=1 ]' branch always selected even if $1 is not 1?
bash;shell;test
Using spaces fixes your problem.if [ $1 = 1 ];    then    shift        mv $@ ~/lab/Sunelif [ $1 = 2 ];    then    shift        mv $@ ~/lab/Moonelif [ $1 = 3 ];    then    shift        mv $@ ~/lab/EarthfiThough this is neater:#!/bin/bashaction=$1shiftfiles=($@)case $action in    1) mv -- ${files[@]} ~/lab/Sun     ;;  2) mv -- ${files[@]} ~/lab/Moon    ;;  3) mv -- ${files[@]} ~/lab/Earth   ;;esac