I’m not experienced with shell scripting. I made this:
#!/bin/bash
function hac() {
echo "test: $1"
javac $1.java && java $1
}
hac SquareDriver
So I have SquareDriver.class in the working directory and this works when I call
./scriptname.sh
However, I would like to make it so I could just call hac filename on the command line and it would execute the function from within this file.
How can I do this?
Put the function definition in your
~/.bashrc. This will makehacavailable in all your terminal sessions.