Hello all, I want to use the mv command in a script named rename.sh, but when i run the command on the prompt (sh rename.sh) i have the error "mv: command not found". The script is in mode 0777. Below you will find the code i want to use. Any help is welcome ! #!/bin/bash PATH="/var/opt/" #Rename before cd $PATH mv "file1.php" "file1.php.org" mv "file1.php.1" "file1.php" exit 0 fi
Try this: Code: #!/bin/bash PATH="/var/opt/"; MV=/bin/mv; #Rename before cd $PATH MV "file1.php" "file1.php.org" MV "file1.php.1" "file1.php" exit 0 fi
I did a "locate mv", and the path where it is /bin/mv, exactly in the way it stands in the script....
Either use Code: #!/bin/bash PATH="/var/opt/"; MV=/bin/mv; #Rename before cd $PATH [B][COLOR="Red"]$[/COLOR][/B]MV "file1.php" "file1.php.org" [B][COLOR="Red"]$[/COLOR][/B]MV "file1.php.1" "file1.php" exit 0 fi or adjust the PATH variable in your original script: Code: #!/bin/bash PATH="[B][COLOR="Red"]/bin:[/COLOR][/B]/var/opt/" #Rename before [B][COLOR="Red"]cd /var/opt[/COLOR][/B] mv "file1.php" "file1.php.org" mv "file1.php.1" "file1.php" exit 0 fi