syntax error: `-a' unexpected operator/operand in IF


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting syntax error: `-a' unexpected operator/operand in IF
# 1  
Old 11-14-2008
syntax error: `-a' unexpected operator/operand in IF

When i tyr this, it gives me a syntax error...i tried removing quotes,removing spaces,replacing -eq with '='.. Can somebody suggest that is the problem?

if [[ "$audit_ftpsize" -eq "$audit_lsize" -a "$details_ftpsize" -eq "$details_lsize" -a "$summary_ftpsize" -eq "$summary_lsize" ]]; then
# 2  
Old 11-14-2008
Are numbers equal, not equal, greater than, etc.?
-eq, -ne, -gt, ...

Are strings the same or different?
=, !=

Try
Code:
if [[ $audit_ftpsize = $audit_lsize && $details_ftpsize = $details_lsize && $summary_ftpsize = $summary_lsize ]]; then


Last edited by Ikon; 11-14-2008 at 04:07 PM..
# 3  
Old 11-14-2008
thanks for the reply Ikon...

i run a script if these variables are equal. so basially i am trying to see if these are equal. it is like '='.
# 4  
Old 11-14-2008
=, !=, <, > are for numbers: 123 = 123 : true
-eq, -ne, -gt, -lt are for strings: jim = jim : true

edit: had them backwards
# 5  
Old 11-14-2008
this seems to work...

if [ $audit_ftpsize = $audit_lsize ] && [ $details_ftpsize = $details_lsize ] && [ $summary_ftpsize = $summary_lsize ]; then
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Syntax error: `]' unexpected

I am getting this error Syntax error: `]' unexpected. Did I do something wrong with elif? Does ksh not like double brackets? if ]; then #echo hi source ~/.bashrc; elif ]; then #echo hi source ~/.kshrc; fi (5 Replies)
Discussion started by: cokedude
5 Replies

2. Shell Programming and Scripting

Newbie question: modulo operator with negative operand, bug or feature?

Hi, I'm new to the Ash shell so my apologies if this is well known. In normal maths and other shells and languages I've used, the modulo operator always returns a positive remainder. For example see this discussion (first post so I can't hyperlink it): ... (11 Replies)
Discussion started by: FleetFoot
11 Replies

3. Shell Programming and Scripting

Getting syntax error with awk ternary operator

split($7,a," "); date = a; time = a split(date,d,"/"); month = sprintf("%02d",d); day = sprintf("%02d",d); year = 2000 + d % 100 split(time,t,":"); hour=t; min=t hour >= 12? { hour=hour-12; amPm=" PM" } : amPM=" AM" hour == 0? hour=12 time=sprintf("%02d",hour)":"sprintf("%02d",min)amPm ... (4 Replies)
Discussion started by: Michael Stora
4 Replies

4. Shell Programming and Scripting

Syntax error: 'fi' unexpected

unzip file.zip if ] ; then echo "Success" else echo "Some failure." fi ; I tried many time to detect the unzip error, but it keep show the syntax error wherever how I change the syntac. Hope someone can help me fix the issue, thanks. Please use code tags next time for your code and... (5 Replies)
Discussion started by: duncanyy
5 Replies

5. Shell Programming and Scripting

Assignment operator without operand

Does anyone know how this line in bash works? local gotbase= force= nicelevel corelimit local pid base= user= nice= bg= pid_file= local cgroup= These lines are part of the daemon function inside the "functions" file at /etc/init.d in RH. (3 Replies)
Discussion started by: Rameshck
3 Replies

6. UNIX for Dummies Questions & Answers

> 5 ")syntax error: operand expected (error token is " error

im kinda new to shell scripting so i need some help i try to run this script and get the error code > 5 ")syntax error: operand expected (error token is " the code for the script is #!/bin/sh # # script to see if the given value is correct # # Define errors ER_AF=86 # Var is... (4 Replies)
Discussion started by: metal005
4 Replies

7. UNIX for Dummies Questions & Answers

syntax error: invalid arithmetic operator

hi, i have a bash script that i want to receive a a string from another bash file. But because the string has a dot in the middle it gives me an error. The error is in this line: let valor=$1 and the value passed is rules.txt the error is: let: valor=rules.txt: syntax error: invalid... (2 Replies)
Discussion started by: limadario
2 Replies

8. Shell Programming and Scripting

how to avoid 'unexpected operator' error when comparing 2 strings

this is my file: #!/bin/sh a=`cat /home/$USER/Desktop/lol` c=`cat /home/$USER/Desktop/lol1` if ; then echo "$a = $c" else echo "They are not equal" fi The lol file contains 1aa and the lol1 file contains 1aa as well. Unfortunately the output is Even when I put -eq instead of == I get ... (9 Replies)
Discussion started by: hakermania
9 Replies

9. Shell Programming and Scripting

syntax error: `$' unexpected

Hi all, Am very new to Unix and am currently Involved in Migrating some Shell Scripts from AIX 4 to Solaris 10. While using teh for loop am getting the below error: $ echo $SHELL /usr/bin/ksh $ for file in $(ls *SEBE*) syntax error: `$' unexpected while the same works without issue on... (4 Replies)
Discussion started by: paragkhanore
4 Replies

10. Shell Programming and Scripting

sh: syntax error: `...' unexpected???

Hello all, I want to create a script that polls every hour a directory for the existence of a file. The file I look for is a `token` dropped by an external process at the completion of a successful FTP process. I wrote this script `checkfile.ksh`: #!/usr/bin/ksh if ] then mailx... (5 Replies)
Discussion started by: alan
5 Replies
Login or Register to Ask a Question