Skip to main content

Thread: simple default variable


i know not correct. want option variable default if option not given on command line.

code:
#!/bin/bash  foo2option=1 foo1 $(foo2 --foo2option $2 $1)
running script no option:
code:
$ ./script somefile
would run:
code:
foo1 $(foo2 --foo2option 1 somefile)
running script option:
code:
$ ./script somefile 2
would run:
code:
foo1 $(foo2 --foo2option 2 somefile)

have @ bash

code:
${parameter-default}, ${parameter:-default}
syntax - should - like

code:
#!/bin/bash  default=2  echo command $1 ${2:-$default}
will use 2nd command line argument $2 if set, , $default otherwise

http://tldp.org/ldp/abs/html/paramet...stitution.html

hope legal! if not i'm sure 1 of real bashistas step in , correct me


Forum The Ubuntu Forum Community Ubuntu Official Flavours Support General Help [SOLVED] simple default variable


Ubuntu

Comments

Popular posts from this blog

Thread: Can not create raid array: mdadm: no raid-devices specified.

Thread: HOW TO: Package and theme GTK+ / Gtkmm apps in Linux for Windows

Thread: Twinview issues