I have a bash script that I use to call a java class and I pass two arguments to this java class. The first argument ($1) is the string that I pass and it contains someone's name. The second argument ($2) is the previous month as a two digit number (also passed in by the user).
So the java class is called like this:
java -DCONFIG_DIR=... com.example.myapp.grades.gradingProcess $1 $2
However, now, I don't want the user to pass in the second argument and instead, I want the script to determine the month.
Can I do something like this?
month=`date +'%m' -d 'last month'`
java -DCONFIG_DIR=... com.example.myapp.grades.gradingProcess $1 $month
And when I run my script, it'll be something like this: ./myscript.sh 'John' and not pass in a two-digit month since I'm already doing it inside the script?
Or is that not the correct way to go about it? Sorry if this seems like an elementary question, I'm still trying to get used to bash scripts.
Thank you?