LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Other *NIX Forums > Solaris / OpenSolaris
User Name
Password
Solaris / OpenSolaris This forum is for the discussion of Solaris, OpenSolaris, OpenIndiana, and illumos.
General Sun, SunOS and Sparc related questions also go here. Any Solaris fork or distribution is welcome.

Notices


Reply
  Search this Thread
Old 07-03-2007, 04:40 AM   #1
ahmedb72
Member
 
Registered: Jan 2006
Location: Sydney
Distribution: RHEL
Posts: 72

Rep: Reputation: 15
using test command


Hi all,
I am trying to expirement the test command here:

Code:
ahmed~>echo $LOGNAME
ahmed
ahmed~>test "$LOGNAME"="ahmed"
ahmed~>echo $?
0
ahmed~>test "$LOGNAME"="xyz"
ahmed~>echo $?
0
Why the command retruns zero in both cases ?
 
Old 07-03-2007, 04:51 AM   #2
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris 11.4, Oracle Linux, Mint, Debian/WSL
Posts: 9,789

Rep: Reputation: 492Reputation: 492Reputation: 492Reputation: 492Reputation: 492
You need to separate the operands from the operator:
Code:
if test "$LOGNAME" = "ahmed"
This is usually done that equivalent but more readable way:
Code:
if [ "$LOGNAME" = "ahmed" ]
 
Old 07-03-2007, 05:15 AM   #3
ahmedb72
Member
 
Registered: Jan 2006
Location: Sydney
Distribution: RHEL
Posts: 72

Original Poster
Rep: Reputation: 15
Thanks a lot.
 
  


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



Similar Threads
Thread Thread Starter Forum Replies Last Post
command-line speed test zmeda Linux - Networking 5 09-22-2014 08:02 AM
BASH - For with a if test command mago Programming 9 05-03-2007 02:15 PM
need sh script command to test if device is present kevinuu Linux - General 2 03-01-2007 06:46 PM
How to test whether a command timeout? DriveMeCrazy Programming 3 01-11-2007 08:21 AM
understanding read command as a test frankie_DJ Programming 11 08-08-2005 01:30 PM

LinuxQuestions.org > Forums > Other *NIX Forums > Solaris / OpenSolaris

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