multiple conditions in if using && operator


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting multiple conditions in if using && operator
# 1  
Old 12-30-2008
multiple conditions in if using && operator

VARIABLE="project"
if [ [ -n "$VARIABLE" ] && [ $VARIABLE == "project" ] ]
then
echo "VARIABLE is not empty"
fi


this is not working what is wrong in the syntax??
# 2  
Old 12-30-2008
Code:
if [[ -n "$VARIABLE"  &&  $VARIABLE == "project" ]]

# 3  
Old 12-30-2008
thanks lorcan

its working ...i wasted one hour on this...
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

SFTP Shell Script Get & Delete && Upload & Delete

Hi All, Do you have any sample script, - auto get file from SFTP remote server and delete file in remove server after downloaded. - only download specify filename - auto upload file from local to SFTP remote server and delete local folder file after uploaded - only upload specify filename ... (3 Replies)
Discussion started by: weesiong
3 Replies

2. Shell Programming and Scripting

GNU & BSD Makefile Directives & Conditions Compatibility

Firstly, I would like to apologize if this is not the appropriate sub-forum to post about GNU/BSD makefile scripting. Though my code is in C++, because I am focusing on the makefile I thought it would go better in shell scripting. Please correct me if I am wrong. Secondly, I am not interested in... (0 Replies)
Discussion started by: AntumDeluge
0 Replies

3. Shell Programming and Scripting

Linux Platform - NDM Script - && Operator

Hi All, I have a requirement where i need to NDM 3 files from LINUX to Mainframe system & trigger a job in mainframe once the 3 files are transmitted successfully. I am getting an error message in the && operator (the code component where i am checking whether step 1/2/3 are completed). ... (2 Replies)
Discussion started by: dsfreddie
2 Replies

4. UNIX for Dummies Questions & Answers

Magic numbers '&' operator problem

Hello everyone, on the man page of "magic(5)" There is explanation "&, to specify that the value from the file must have set all of the bits that are set in the specified value" . My question is that what is the difference between '&' and equal operator '=' ? I tested it with file... (6 Replies)
Discussion started by: segmentation
6 Replies

5. Shell Programming and Scripting

How to write If statement using && and operator in Unix

Hi What is the syntax for if statement using && and || operator? if && ] || here its giving me an error to this if statement any suggestion?? (2 Replies)
Discussion started by: Avi
2 Replies

6. Shell Programming and Scripting

How to use logic NOT operator for multiple AND conditions

Hi, my requirement is that my builds should not be built if the current hour is greater 3 but not (between 12 and 15), I'm trying to write a shell script for this but there is always an error hour=$1 echo "hour:$hour" if && ! && ]; then echo "exit" else echo "enter" fi ... (9 Replies)
Discussion started by: kgsrinivas
9 Replies

7. Shell Programming and Scripting

Alternative to && operator

"Both cases have to be true for the expression to evaluate "true". is that not so. the following code does a read from a txt file, an then suppose to do the deletion ,but although the condition exists, its not performing the deletion && echo "\n\t Deleting printer ${prt} !!!" if !... (5 Replies)
Discussion started by: ggoliath
5 Replies

8. Shell Programming and Scripting

PHP read large string & split in multidimensional arrays & assign fieldnames & write into MYSQL

Hi, I hope the title does not scare people to look into this thread but it describes roughly what I'm trying to do. I need a solution in PHP. I'm a programming beginner, so it might be that the approach to solve this, might be easier to solve with an other approach of someone else, so if you... (0 Replies)
Discussion started by: lowmaster
0 Replies

9. Shell Programming and Scripting

Find & Replace string in multiple files & folders using perl

find . -type f -name "*.sql" -print|xargs perl -i -pe 's/pattern/replaced/g' this is simple logic to find and replace in multiple files & folders Hope this helps. Thanks Zaheer (0 Replies)
Discussion started by: Zaheer.mic
0 Replies

10. Shell Programming and Scripting

if statement with two conditions -e, &&

Wow I'm so zoned out I don't even know if I posted this question up already (I couldn't find it in my book marks or in "yesterday's" post). My question is, I'm writing a korn script that does something like the following, but I don't yet completely understand the syntax. I need to check that... (16 Replies)
Discussion started by: yongho
16 Replies
Login or Register to Ask a Question