How to reference Main once only in this ubuntu terminal command: “javac Main.java && java Main”?
I am reviewing a number of different java programs and am trying to work out how I can update the reference to the program name once only instead of twice. Is there a way to use a variable in a single terminal command? :S The command I'm trying to improve is of this form: javac Main.java && java Main I only want to change the reference to Main once instead of typing it twice each time. You can do it with one line like this: PC=com/mycompany/Main && CN=$(echo $PC | tr / .) && javac $PC.java && java $CN This will work even if you have a package name as it will automatically replace / with . to