Bash script to move files
I'm a beginner and I need help.
I'm trying to make a script to move some files from one directory in another directory. Before to create the script I tested the command and it was working:
mv /path/to/source /path/to/destinationAfter I've made the script with nano:
#!bin/bash/
echo "mv /path/to/source /path/to/destination"I've made the script executable with: chmod +x fileand then executed as ./file but the following error appears:
bash: ./move.sh: /bin/bash/: bad interpreter: Not a directoryI tried and with sudo ./file and bash file but it’s not working.
I'm using Ubuntu installed with VirtualBox.
11 Answer
That's because you used #!bin/bash/ and this is wrong. The right way is:
#!/bin/bashThis is called a shebang and it tells the shell what program to interpret the script with, when executed.
Another thing: the absolute path for bash interpreter in Ubuntu is /bin/bash, not bin/bash/ or something else. You can check this using which bash command.
And another thing, but probably you know this: the following line:
echo "mv /path/to/source /path/to/destination"will only display a text message with mv /path/to/source /path/to/destination. To really move files use the following script:
#!/bin/bash
mv /path/to/source /path/to/destinationThat is how your script should look like.
1More in general
"Zoraya ter Beek, age 29, just died by assisted suicide in the Netherlands. She was physically healthy, but psychologically depressed. It's an abomination that an entire society would actively facilitate, even encourage, someone ending their own life because they had no hope. Th…"