OT: bash help
Mark C. Allman
mcallman at allmanpc.com
Sat Aug 16 23:14:35 UTC 2014
On Sun, 2014-08-17 at 00:42 +0200, Suvayu Ali wrote:
> On Sat, Aug 16, 2014 at 02:44:14PM -0700, Mike Wright wrote:
> > Hi all,
> >
> > I'm trying to write a simple script that if provided an argument, uses that,
> > or if nothing is provided, uses a predefined string.
> >
> > if [ -n $# ]
>
> This will always be true. -n tests if a string is empty or not. 0
> counts as non-empty. You should use one of the comparison operators.
> Try something like this:
>
> [ $# -gt 0 ]
>
> Hope this helps,
>
> --
> Suvayu
>
> Open source is the future. It sets us free.
Are you looking for behavior that the following test script
demonstrates?
#!/bin/bash
theArg=${1:-The Default Value}
echo $theArg
--
Mark C. Allman, PMP, CSM
Founder, See How You Ski, www.seehowyouski.com
617-947-4263, Twitter: @allmanpc
More information about the users
mailing list