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.

comparing two strings

Shell Programming and Scripting


Closed    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 10-15-2008   -   Original Discussion by infyanurag
infyanurag infyanurag is offline
Registered User
 
Join Date: Nov 2007
Last Activity: 7 November 2014, 8:44 AM EST
Posts: 86
Thanks: 7
Thanked 0 Times in 0 Posts
comparing two strings

hi All

i am facing prob in comparing two strings that have two word.
below is the code snippet.
checkValidates="file validates"
file3_name="file"
if [ $checkValidates = "$file3_name validates" ]
then
echo "file" $file3_name "is validated successfully"
fi

when i run this i get the error as -bash: [: too many arguments

am i doing something wrong?
Please help..

Thanks
Sponsored Links
    #2  
Old Unix and Linux 10-15-2008   -   Original Discussion by infyanurag
agn agn is offline
Registered User
 
Join Date: Feb 2008
Last Activity: 6 August 2013, 7:49 AM EDT
Posts: 345
Thanks: 0
Thanked 21 Times in 21 Posts

Code:
if [ "$checkValidates" = "$file3_name validates" ]

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
Comparing strings with sed cola Shell Programming and Scripting 7 08-22-2010 12:51 PM
comparing 2 strings satish@123 Shell Programming and Scripting 2 05-16-2008 08:59 AM
comparing strings agarwal Shell Programming and Scripting 3 04-16-2008 06:29 AM
Comparing Two Strings Anji Shell Programming and Scripting 8 01-09-2008 06:32 AM
Comparing strings yakyaj UNIX for Advanced & Expert Users 2 03-23-2007 02:22 AM



All times are GMT -4. The time now is 07:43 PM.