LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 11-22-2010, 01:03 PM   #16
ee437
LQ Newbie
 
Registered: Oct 2010
Location: Wisconsin, USA
Distribution: Slackware
Posts: 12

Rep: Reputation: 4

that's interesting, thank you!

i always have used two = signs. i just tested it, and it seems to work regardless of using one or two.

and i didn't know that you didn't always need the semicolon.

thanks again. i hope i didn't cause any confusion.
 
Old 11-22-2010, 01:08 PM   #17
pwc101
Senior Member
 
Registered: Oct 2005
Location: UK
Distribution: Slackware
Posts: 1,847

Rep: Reputation: 128Reputation: 128
Quote:
Originally Posted by ee437 View Post
that's interesting, thank you!
That's OK.
Quote:
Originally Posted by ee437 View Post
i always have used two = signs. i just tested it, and it seems to work regardless of using one or two.
That's because you're probably running bash (which is a bit more flexible than sh). If you can get hold of a system with proper sh installed (as opposed to a symlink to bash), or you use a more POSIX compatible shell (dash is one such shell, I believe), then the [ $var1 == $var2 ] syntax would fail.
Quote:
Originally Posted by ee437 View Post
and i didn't know that you didn't always need the semicolon.
As I said, it's only the case when you have the then on the same line as the if statement:
Code:
if [ $var1 = $var2 ]; then
and
Code:
if [ $var1 = $var2 ]
then
These two are synonymous. Some projects prefer one style over the other (I prefer the former, but that's just my opinion ).
Quote:
Originally Posted by ee437 View Post
thanks again. i hope i didn't cause any confusion.
No problem. At least this way everyone's sure
 
  


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
[SOLVED] Bash script to get PID of a specific process. arashi256 Linux - Newbie 6 08-23-2010 08:45 AM
how to get the specific text from a txt file in bash script deepakdeore2004 Programming 8 04-30-2010 07:35 AM
Bash script to search for specific pattern? jimyg10 Programming 22 05-18-2007 02:02 PM
BASH script to copy specific files ScottReed Linux - Software 5 07-20-2006 12:08 PM
bash-script: output text between two ocurrences of a specific string isl01jbe Programming 1 06-17-2004 03:36 PM


All times are GMT -5. The time now is 05:03 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration