Two condition in if statement

Hi,

I need to put two condition in if statement, but it is not working. Please suggest.


if [ $var -le 10 && $var -ne 0 ]

---------- Post updated at 07:05 AM ---------- Previous update was at 06:55 AM ----------

Also when i put below command in script it is not running, but manually it is running

#folder=`ll /FOLDER/ | wc -l`

#echo $folder
1

But when put in script it gives error.

]# sh m.sh
m.sh: line 1: ll: command not found
0

Try this

akshay@Lenovo-E49:~$ var=4
akshay@Lenovo-E49:~$ if [[ $var -le 10 && $var -ne 0 ]];then echo "Yes";fi
Yes

stop using grave accents it's not good way

akshay@Lenovo-E49:~$ cat test.sh
#!bin/bash

FOLDER=$(ls -alF | wc -l)
echo $FOLDER
akshay@Lenovo-E49:~$ sh test.sh 
86

checkout your .bashrc

alias ll='ls -alF'

Try:

if [ $var -le 10 ] && [ $var -ne 0 ]

You should export the folder variable in order to make it available in subshells.

There are two kinds of test, with different syntax.
Two [test] commands or two [[test]] compounds; the logical AND is handled by the shell:

if [ $var -le 10 ] && [ $var -ne 0 ]
if [[ $var -le 10 ]] && [ $var -ne 0 ]

The logical AND is handled by the [test] command or the [[test]] compound:

if [ $var -le 10 -a $var -ne 0 ]
if [[ $var -le 10 && $var -ne 0 ]]