I am learning to do some bash programming on my new EmperorLinux lenovo T61
(prideful plug) and am having a problem in attempting to determine if an
argument was included when the bash file was started. I can perform a printf
statement and it prints whatever I add as an argument but I am attempting to
do an 'if/then' statement.
desnotes@tardis:~# ./read_history.sh 15 #15 added as argument
desnotes@tardis:~# ./read_history.sh #no argument
Snippet:
.
.
.
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
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:00 EDT