LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 01-18-2005, 08:28 PM   #1
izza_azhar
LQ Newbie
 
Registered: Jan 2005
Location: malaysia
Posts: 18

Rep: Reputation: 0
comparison


if -ge =greater /equal
-le = less/ equal

what if we want just equal
i cannot used (=)

eg:
if [ $file_year = $curr_year ]
echo "..."
fi

if [ $file_year = $curr_year + 1 ]--> this comparison also wrong
echo"...
else
echo"....
fi
 
Old 01-18-2005, 08:35 PM   #2
jtshaw
Senior Member
 
Registered: Nov 2000
Location: Seattle, WA USA
Distribution: Ubuntu @ Home, RHEL @ Work
Posts: 3,892
Blog Entries: 1

Rep: Reputation: 67
==
 
Old 01-19-2005, 02:58 PM   #3
jonaskoelker
Senior Member
 
Registered: Jul 2004
Location: Denmark
Distribution: Ubuntu, Debian
Posts: 1,524

Rep: Reputation: 47
run 'man test' or 'info test'
 
Old 01-19-2005, 05:28 PM   #4
twantrd
Senior Member
 
Registered: Nov 2002
Location: CA
Distribution: redhat 7.3
Posts: 1,440

Rep: Reputation: 52
Since this is numerics, use -eq for equal.

a=1
b=1

if [ $a -eq $b ]; then
echo "A and B are equal"

exit 0

-twantrd
 
Old 01-19-2005, 11:57 PM   #5
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 7.7 (?), Centos 8.1
Posts: 17,850

Rep: Reputation: 2585Reputation: 2585Reputation: 2585Reputation: 2585Reputation: 2585Reputation: 2585Reputation: 2585Reputation: 2585Reputation: 2585Reputation: 2585Reputation: 2585
You may find this handy
http://www.tldp.org/LDP/abs/html/index.html
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Comparison introuble Programming 1 01-18-2005 02:57 PM
OS Speed Comparison Tarential Linux - General 4 01-20-2004 09:02 PM
Comparison halobungie Linux - Newbie 4 08-10-2003 03:55 PM
Not your standard WM comparison. adz Linux - Software 3 07-27-2003 11:04 PM
*comparison in C simbo Programming 2 04-22-2003 11:05 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 02:07 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