I am trying to make a shell script which will ask some questions to the user, and will issue a final command with some or other options depending on what the user chose. Right now, the script looks like this:
if [[ $a == "y" ]] ; then command --option 1 argument elif [[ $a == "n" ]] ; then command --option 2 argument else command --option 3 argument fi
Considering the command is very long, and contains a lot of options and arguments which remain constant between the different statements, I was wondering if I could in some way write a single line, with variable options being considered only if the corresponding condition is true.
This also applies to
GNU parallel issuing one or more commands
if [[ $b == "n" ]] ; then find ./ -name '*.extension' | parallel -j $(nproc) command1 --option argument else find ./ -name '*.extension' | parallel -j $(nproc) command1 --option argument\; command2 --option argument