If -elif-else error.


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting If -elif-else error.
# 1  
Old 01-10-2011
If -elif-else error.

I am getting below error from this code (which is at line 24):
Code:
if [["${File_count}" -gt 0 && "${File_flag}" == "Y"]] #this is line24 in code
        then
        mv $File_source_path/$File_name $File_name'_'`date '+%d%m%y'`

Error:
Code:
line 24: [[      1: command not found

Any help with the syntax. I am putting 2 condition with 'AND' clause.
This is bash shell.

Last edited by Scott; 01-10-2011 at 08:18 PM.. Reason: Code tags, please...
# 2  
Old 01-10-2011
did you try putting space after [[ and before ]] ?

so like this?
Code:
if [[ "${File_count}" -gt 0 && "${File_flag}" == "Y" ]]


Last edited by Scott; 01-10-2011 at 08:19 PM.. Reason: Code tags
# 3  
Old 01-10-2011
Worked!!!!. thanks
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

If / elif

Hello all, I have a scenario where I take user input values and accordingly take actions say I run a script with sh scriptname -x GB -e txt (txt can also be text) I have used if clause for the first input (-x GB)and it is working fine Now for second the scenario is if then echo... (3 Replies)
Discussion started by: nnani
3 Replies

2. UNIX for Advanced & Expert Users

if else elif

Hi all,i have configured the following script to check if the file exists or not, #!/bin/sh sleep 30 { FILEFULL=$1`date +$2`* if ; then echo $FILEFULL exist else echo "$FILEFULL File not Found" | mail -s 'server' myaccount@mydomain.com fi } but i have a problem, i need to... (2 Replies)
Discussion started by: charli1
2 Replies

3. Shell Programming and Scripting

Syntax error near unexpected token 'elif'

Solaris 10 This is my script: #!/bin/bash #Script to print number of users and print list of them NO=`awk < /etc/passwd -F: '{ print $1 }' | wc -l` echo There are $NO users on system. echo "Do you want me to list them? (y or n):" read YORN if ] awk < /etc/passwd -F: '{ print $1 }'... (5 Replies)
Discussion started by: kaustubh
5 Replies

4. Homework & Coursework Questions

if/elif help

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: This is my problem for the class. Write a script that asks for the user's age. If it is equal to or higher... (6 Replies)
Discussion started by: aggie6970
6 Replies

5. Shell Programming and Scripting

elif syntax error?

Hello, first off, let me begin by saying that I am a complete GNU/linux noob. I installed it on my laptop not even a month ago, because I've gotten tired of Windows on my laptop, but anyway. I'm starting to write bash shell scripts, and one of my friends who found out that I was starting this and... (8 Replies)
Discussion started by: Puddles187
8 Replies

6. Shell Programming and Scripting

Query on If-Elif!!

Script Gurus, Need your help in getting this script to come out of logical error : I have pasted the script below: This script finds disk utilzation ... the script is written for both AIX and SUN OS... and option will be given in the initial to select DB or Non DB... its required for my prj...... (1 Reply)
Discussion started by: vangalli
1 Replies

7. Shell Programming and Scripting

syntax error near unexpected token `elif'

what is wrong with the below script: --------------------------------------------------------------------------------- #!/bin/bash echo "Setting JrePath..." grep -w "export JrePath" /etc/profile Export_Status=$? if echo "JrePath declared" elif echo "JrePath not declared" echo... (2 Replies)
Discussion started by: proactiveaditya
2 Replies

8. Shell Programming and Scripting

If..elif..else...fi

Hi all, I got some problems on executing the following scripts. Scripts: if ]; then echo "M${str}O 0 1" >> ${tempFile} elif ]; then echo "M${str}O 1 0" >> ${tempFile} else echo "M${str}O 0 0" >> ${tempFile} fi Error: "`;' is not expected." what's the problem? (2 Replies)
Discussion started by: Rock
2 Replies

9. UNIX for Dummies Questions & Answers

syntax error at line 33: `elif` unexpected

#!/bin/sh echo "Choose option: e, d, l, t, p, or x." read option if test $option = e then echo "Filename?" read file if test ! -f $file then echo "No such file" else echo "Yes its a file" fi ... (4 Replies)
Discussion started by: hazy
4 Replies

10. Shell Programming and Scripting

elif not expected

Hi, I have a shell script which runs fine when i do it from Unix simulator on Widnows. When i try to run the same for Unix it throws me the error syntax error at line 87: `elif' unexpected. Piece of code for the same is while do if ; then shift configFile="$1"... (9 Replies)
Discussion started by: pv0428
9 Replies
Login or Register to Ask a Question