Comments on: Bash Script Examples https://www.rosehosting.com/blog/bash-script-examples/ Premium Linux Tutorials Since 2001 Fri, 03 Jun 2022 08:32:42 +0000 hourly 1 https://wordpress.org/?v=6.5.2 By: peter teuben https://www.rosehosting.com/blog/bash-script-examples/#comment-48426 Sun, 13 Sep 2020 23:31:41 +0000 https://www.rosehosting.com/blog/?p=33968#comment-48426 I often love to set defaults for shell variables, and allow them to be overridden by a command line set of “keyword=value”. Admittedly horribly fragile, and with getopt there are better –options, but you can hardly beat the simplicity?

a=1
b=2
# simple keyword=value command line parser for bash
for arg in $*; do\
export $arg
done

#now use your variables
echo a=$a b=$b

]]>