/ Published in: Bash
Expand |
Embed | Plain Text
#!/bin/bash # DEFAULT VALUES default_output_format='txt' default_position_column_width=40 # SUPPORTING FUNCTIONS function display_usage { echo "Usage: `basename $0` [-o (txt|csv)] [-wp <integer>] [-h]" echo " where" echo " -o : Specifies the output format (txt or csv). Default is '${default_output_format}'." echo " -wp : Specifies the width of the 'Position' column. Default is ${default_position_column_width}." echo " -h : Display this usage." exit } # ASSIGN DEFAULT VALUES position_column_width=$default_position_column_width output_format=$default_output_format # GET COMMAND LINE ARGUMENTS while [ $# -gt 0 ] do case $1 in '-o') output_format=$2 shift 2 ;; '-wp') position_column_width=$2 shift 2 ;; '-h') display_usage ;; *) echo "Error: unknown argument '$1'." display_usage ;; esac done
You need to login to post a comment.
