The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Compare & replace contents within a file kaustubh137 Shell Programming and Scripting 2 05-27-2008 06:56 AM
A final question! Compare character with each array element rorey_breaker Shell Programming and Scripting 1 09-28-2007 09:26 AM
Can I assign the contents of file into an array? murtaza Shell Programming and Scripting 10 03-28-2007 03:58 AM
converting contents of a character array to int jyotipg High Level Programming 5 07-19-2006 09:18 PM
Creating file contents using contents of another file ReV Shell Programming and Scripting 21 02-24-2006 10:25 AM

Closed Thread
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
  #1 (permalink)  
Old 03-25-2008
orahi001 orahi001 is offline
Registered User
  
 

Join Date: Dec 2007
Posts: 48
compare array contents with file

I have an array "arrA" with the following contents:
Code:
A0012 Paint Shop.doc
ES001 Contract Signature.doc
Budget Plan.pdf
TS PWS.pdf
My data file "Files.dat" has the same contents:
Code:
A0012 Paint Shop.doc
ES001 Contract Signature.doc
Budget Plan.pdf
TS PWS.pdf
I have a script that compares the two and prints mismatches, but I'm getting unexpected output.

Code:
sizeA=${#arrA[*]}
ia=0
while [ $ia -lt $sizeA ]
do 
  sed -n "/${arrA[$iia]}/!p" Files.dat > mismatches.dat

   ((ia=ia+1))
done
expected output show be empty file:


actual output:
Code:
A0012 Paint Shop.doc
ES001 Contract Signature.doc
Budget Plan.pdf
TS PWS.pdf
Basically, if the element in the array isn't in the file then print to mismatches.dat.


Can anyone point out what is wrong here or supply an alternate method?



thanks

Last edited by Yogesh Sawant; 03-26-2008 at 01:29 AM.. Reason: added code tags
Closed Thread

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 04:23 PM.


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