![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| 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 |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
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 |
| Display Modes | Rate This Thread |
|
|