#!/bin/bash script_args=() while [ $OPTIND -le "$#" ] do # fetch the -Xmx option for java machine if getopts X: option then case $option in X) JAVAOPTS="-X$OPTARG";; esac else # paste all the rest of the command line script_args+=("${!OPTIND}") ((OPTIND++)) fi done java $JAVAOPTS -jar /opt/picard.jar ${script_args[@]}