mkdir inside sh, won't work

I am trying to create directory using mkdir inside sh file, when I do that the directory is created, but then when trying to do something to it, I get the message "rm: cannot remove '/testFolder': No such file or directory", but it is there...

What am i doing wrong?

this is my sh file

#!/bin/sh
mkdir -p /testFolder
wget -O /testFolder/server.jar
echo "cd /testFolder\njava -Xmx1024M -Xms1024M -jar server.jar nogui" >> /testFolder/startMc.sh

then i call the file sudo sh test.sh

9

1 Answer

The new line \n is not being interpreted by the echo command try adding the -e argument to echo:

#!/bin/sh
mkdir -p /testFolder
wget -O /testFolder/server.jar
echo -e "cd /testFolder\njava -Xmx1024M -Xms1024M -jar server.jar nogui" >> /testFolder/startMc.shenter code here
1

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like