If condition giving syntax error. Need help.


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting If condition giving syntax error. Need help.
# 1  
Old 08-06-2015
If condition giving syntax error. Need help.

Hi,

I have an if condition on executing it is giving syntax error as below:
--------------------------------------------------------------------------------------
Code:
line 61: syntax error in conditional expression
./play_test.sh: line 61: syntax error near `]'
./play_test.sh: line 61: `      if [[ "${Input_parameters[0]}" = "-h" ] || [ "${Input_parameters[0]}" = "--help" ] || [ "${No_of_input_params}" -lt 0 ]]'

--------------------------------------------------------------------------------------
What may be the issue?

Line 61 code is as below:
--------------------------------------------------------------------------------------
Code:
if [[ "${Input_parameters[0]}" = "-h" ] || [ "${Input_parameters[0]}" = "--help" ] || [ "${No_of_input_params}" -lt 0 ]]

--------------------------------------------------------------------------------------

Please help.

Regards,
Ramki

Last edited by Scrutinizer; 08-06-2015 at 06:32 AM.. Reason: CODE tags
# 2  
Old 08-06-2015
The last test has double square brackets when you opened with a single bracket
# 3  
Old 08-06-2015
remove the inner single brackets:
Code:
if [[ ${Input_parameters[0]} = "-h" || ${Input_parameters[0]} = "--help"  ||  ${No_of_input_params} -lt 0 ]]

Note that the single = is ksh 88 syntax. Bash / ksh93 and zsh require a double == . Also, number of input parameters less than zero?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. HP-UX

HP-UX: Shell Script giving " 0^J30: Syntax error"

Hi All, We are getting a very unique error while running a shell script on HP-UX box. Can somebody help in this regards? The shell script is working fine on linux/solaris box. Error: ++++++++++++++++++++++++ $/test.sh ./test.sh: 0^J30: Syntax error $ ++++++++++++++++++++++++ TIA.... (16 Replies)
Discussion started by: vai_sh
16 Replies

2. AIX

multipath giving error

Hi, # lspath Missing hdisk0 fscsi0 Missing hdisk1 fscsi0 Missing hdisk2 fscsi0 Missing hdisk3 fscsi0 Missing hdisk4 fscsi0 Missing hdisk5 fscsi0 Missing hdisk6 fscsi0 Missing hdisk7 fscsi0 Missing hdisk8 fscsi0 Missing hdisk9 fscsi0 Missing hdisk10 fscsi0 Missing hdisk11... (2 Replies)
Discussion started by: JATA01
2 Replies

3. Shell Programming and Scripting

syntax of if condition in ksh is wrong

The syntax of 'if' conditionals in bash and ksh seems different. I am trying to check for a particular version using 'if' in ksh. This very simple syntax gives syntax error. I have tried many variants, but no go. Please correct the syntax. Later I will expand it to 'if' and 'else'. #!/bin/ksh... (8 Replies)
Discussion started by: nivedhitha
8 Replies

4. Shell Programming and Scripting

Help with IF Condition Syntax

Hi. I expect the following unix script command to return 8: ls -ltr dropez* | grep -c dropez I can't seem to find the correct syntax (borne shell), can anyone help be to write an IF condition something like this: IF (ls -ltr dropez* | grep -c dropez) = 8 THEN ...do stuff ELSE ...do... (4 Replies)
Discussion started by: buechler66
4 Replies

5. Shell Programming and Scripting

set -o vi giving set: Syntax error

when trying : set -o vi getting error like- : set: Syntax error help me Double post (of sorts). Continue here. (0 Replies)
Discussion started by: RahulJoshi
0 Replies

6. Shell Programming and Scripting

bc giving error: (standard_in) 2: parse error

Below part of script, is working fine sometimes and gives error sometime. I am doing float operations, checking if x > y. ##########CODE########## THRESHOLD="1.25" ratio=$( echo "scale=2; ${prev}/${current}" | bc ) if ; then split_date=`echo ${line} | cut -d, -f2` fi ... (9 Replies)
Discussion started by: manishma71
9 Replies

7. Solaris

useradd giving error in solaris 10

Hi, I have installed Solaris 10 in my PC and now installing Oracle10, but while adding a user i am getting following error: useradd -g oinstall -G dba -d /export/home/oracle oracle UX: useradd: ERROR: Inconsistent password files. See pwconv(1M). I have tried pwconv command,... (4 Replies)
Discussion started by: amitanshu.verma
4 Replies

8. BSD

Xarchiver giving error messages

I have FreeBSD installed with Xarchiver and when extracting files through the file manager ("Extract here..." option) the following error pops up: tar: unrecognized option `--overwrite' Perhaps this is a known error and is there a way to solve it? (10 Replies)
Discussion started by: figaro
10 Replies

9. UNIX for Advanced & Expert Users

script giving error

Hi All, i have an small issue... echo " " eval x=$@ export x=`echo $x` echo $x ssh user@ipadrss; cd /mbbv/home/; cd /mbbv/home/orange/orange/ echo pwd bash samplescript.sh $x above is my script which will triger from server A and will connect to server B for some... (2 Replies)
Discussion started by: Shahul
2 Replies

10. UNIX for Dummies Questions & Answers

/dev/rStp0 giving error

I do my backups using the following command find / -print |cpio -ocv >/dve/rStp0 It has been working fine for ages and suddenly I am getting this error :- Reached end of medium on output If you want to go on type device/file name when ready This happens after you press enter when... (1 Reply)
Discussion started by: workingstiff
1 Replies
Login or Register to Ask a Question