Re: [SLUG] Bash Help Needed

From: Michael Fisher (desnotes@gmail.com)
Date: Sat May 17 2008 - 14:09:46 EDT


I tried putting the $1 in double quotes ("$1") and tried the but no
luck...would it be easier to determine if the argument ($1) exists or not?
If so, how would I do that?

thanks,

Mike

On Sat, May 17, 2008 at 1:37 PM, James Forte <james@magna.net> wrote:

> quote the $1 as in "$1"
>
> ---------------------------------------------------------------
> James Forte, Magna Timeshare Software
> http://www.magna.net/ mailto:James@Magna.Net
> -----------------------------------------------------------------
>
>
> On Sat, 17 May 2008, Ron Youvan wrote:
>
> printf "argument= %s\n" "$1" #works correctly
>>>
>>
>> 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
>>>
>>
>>
>> #!/bin/bash
>> # /usr/local/bin/bed
>> # by Ron KA4INM Youvan
>> if
>>
>> Here my "if" is on line #4, is that right?
>> if there is no command -eq you may need to put -e -q
>>
>> My "bash" book is for version 2.0 so it is out of date.
>>
>>
>> --
>> Ron KA4INM - The harder I work, the behinder I get!
>> -----------------------------------------------------------------------
>> 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 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 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:12 EDT