Unique project path in bat file

I'm beginner in Linux environment. I moved my project with automated tests from Windows to Linux Ubuntu. In windows I have following bat file:

set projectPath=D:\git\testproject
cd %projectPath%
mvn clean test -Dxmlfile=dev.xml
pause

How can I create unique projectPath in Linux? Should I write a path variable?


Solution 1:

Sample conversion from bat to bash

#!/bin/bash
# Old bat lines are commented out
# set projectPath=D:\git\testproject
PROJECTPATH="home/admin/projects/testproject"
#cd %projectPath%
cd "$PROJECTPATH"
mvn clean test -Dxmlfile=dev.xml
#pause
read -p "Press the Enter key to continue" x 

Save this code in a file. Give it a name, something like mymvn or mymvn.sh. Save the file in ~/bin. See Where should I put my bash scripts for why.

Now you type the name of the bash file in the terminal to run these commands.

Some background

The first line is called shebang. See What is "#!' in a script file? for more.

Linux is case sensitive. See Correct Bash and shell script variable capitalization. Also note, file and folder names are case sensitive too.

There is no pause command in bash. I used the read command. It waits for a keyboard input. This will keep the terminal open until you hit the Enter key.

Hope this helps