Unix/Linux Go Back    


Shell Programming and Scripting BSD, Linux, and UNIX shell scripting Post awk, bash, csh, ksh, perl, php, python, sed, sh, shell scripts, and other shell scripting languages questions here.

equal to operator

Shell Programming and Scripting


Closed    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 02-08-2010
anijan anijan is offline
Registered User
 
Join Date: Feb 2010
Last Activity: 12 April 2016, 3:14 AM EDT
Location: Chennai, India
Posts: 38
Thanks: 2
Thanked 0 Times in 0 Posts
equal to operator

Hi,
I have the below script executed


Code:
arg="dir"
if "$arg" = "dir"
then
    echo "true"
else
    echo "false"
fi

Please let me know what happens in the if command.
My output is:

dir: dir: No such file or directory
false
which is not the desired output.
When i used test command it works fine.
Please explain the significance of = (and if command) in the above code.
Sponsored Links
    #2  
Old Unix and Linux 02-08-2010
Franklin52's Unix or Linux Image
Franklin52 Franklin52 is offline Forum Staff  
Moderator
 
Join Date: Feb 2007
Last Activity: 25 November 2016, 10:15 AM EST
Location: The Netherlands
Posts: 7,746
Thanks: 139
Thanked 558 Times in 520 Posts
You can have a read of:

BASH Programming - Introduction HOW-TO: Conditionals

Regards
Sponsored Links
Closed

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Regex NOT EQUAL help ArterialTool Shell Programming and Scripting 6 08-13-2009 06:52 PM
awk check for equal - help uwork72 Shell Programming and Scripting 12 02-27-2009 06:12 AM
Edit entry if not equal kenshinhimura Shell Programming and Scripting 4 08-07-2008 12:18 AM
Stop+A equal tlee Solaris 5 07-01-2008 07:42 AM
add not equal in script. myguess21 Shell Programming and Scripting 2 02-26-2008 10:20 AM



All times are GMT -4. The time now is 05:48 PM.