The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
search two words in sed ajitkumar2 Shell Programming and Scripting 12 08-01-2008 04:00 AM
similar words Streetrcr UNIX for Dummies Questions & Answers 1 03-22-2008 09:24 AM
sed [delete everything between two words] Orbix UNIX for Dummies Questions & Answers 3 12-25-2007 08:27 AM
Get the words.. kakashi_jet Shell Programming and Scripting 10 07-31-2006 10:30 AM
Looking for Words File OC Del Guy UNIX for Dummies Questions & Answers 9 04-12-2006 08:27 AM

 
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 03-18-2009
luna_soleil luna_soleil is offline
Registered User
  
 

Join Date: Feb 2009
Posts: 33
Comparing 2 words

Hi

I have assigned list of arrays as below:
rtab[1]="TAB1 Y"
rtab[2]="TAB2 Y"
rtab[3]="TAB3 Y"
rtab[4]="TAB4 Y"

And I have a text file comp.txt that contains
>vi comp.txt
TAB1 Y
TAB2 Y
TAB3 Y
TAB4 Y

I want to compare the content of the array with the content in comp.tx.. so I have written the code as below :

i=0
while read ttab
do
arr[$((i=i+1))]=$ttab
if [ $ttab = ${rtab[i]} ]
then
echo "${rtab[i]} -> status is Y [PASS]"
else
echo "${rtab[i]} -> status is N [FAIL]"
fi
done < comp.txt

But unfortunately I've been getting output ..status is N [FAIL] everytime i run this script.
Is this because the script can't compare 2 words TAB Y ("TAB2 Y" compare with "TAB2 Y" is not permitted, "TAB" compare with "TAB" is OK)?
If yes, how do I rectify this?

Thank u very much

Last edited by luna_soleil; 03-18-2009 at 02:06 PM..
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 09:46 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0