LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 01-23-2007, 11:08 PM   #1
tmaxx
LQ Newbie
 
Registered: Jun 2006
Posts: 21

Rep: Reputation: 15
basic if then else syntax question


newbie here.. how do i write if x is greater than y but less than z


is it if [ x -gt y -lt z]?

or is it if [ x -gt y ] or [x -lt z]

pls help
 
Old 01-23-2007, 11:31 PM   #2
matthewg42
Senior Member
 
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 65
In borne style shells, the syntax is something like this:
Code:
#!/bin/bash

a=4
b=6
c=1

# Single condition
if [ $a -lt $b ]; then
    echo "$a is less than $b"
fi

# multiple conditions, not this could also be written
# as [ $b -ge $c ]
if [ $b -gt $c ] || [ $b -eq $c ]; then
    echo "$b is greater than or equal to $c"
fi
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
question about C++ syntax bx.s Programming 3 07-27-2006 07:50 PM
C++ syntax question jiml8 Programming 6 06-20-2006 04:19 PM
Syntax question satimis Linux - Newbie 9 09-23-2004 07:47 AM
Syntax question satimis Linux - Newbie 4 10-08-2003 09:33 PM
help with basic syntax in bash script Supp0rtLinux Linux - Software 4 03-27-2003 06:57 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 12:25 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration