Re: [SLUG] Bash Help Needed

From: ronan (ronan@tampabay.rr.com)
Date: Sat May 17 2008 - 14:57:05 EDT


I've noticed that bash is very whitespace sensitive (well, not 'very',
but compared to C...) Put spaces around all of your arguments:

if [ $1 -eq "" ]; then

the missing space before the $1 might be a problem?

--ronan
>
> if [$1 -eq ""]; then
> cnt=10
> printf "$1 is blank\n" "$cnt"
> else
> printf "$1 is not blank\n" "$cnt"
> cnt=$1
> fi
>
> printf "cnt=%s\n" $cnt
>
> Error:
> If there is no argument I get this message: line 9: -eq: command not found
> If there is an argument of 15: line 9: 15: command not found
>
> Anyone have any idea what I am doing wrong? line 9 is the 'if' statement
>
> Thanks,
>
> Mike Fisher
>
>

-----------------------------------------------------------------------
This list is provided as an unmoderated internet service by Networked
Knowledge Systems (NKS). Views and opinions expressed in messages
posted are those of the author and do not necessarily reflect the
official policy or position of NKS or any of its employees.



This archive was generated by hypermail 2.1.3 : Fri Aug 01 2014 - 15:51:35 EDT