This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Issues with read and loop in bash


Hello @all, 

I`m new to this group, so please apologize if my posting does not conform to
formal restrictions. ;-)

In addition, my english is quite poor, so please apologize this too. ;-)

Well, I have following problem. I searched this already in the gmane-database
for this newsgroup, but didn`t find an appropriate answer. (possible bad
searchwords?)

I wrote a shell script using bash at Suse 9.1.
This shell script includes following section:
----------------snip-------------------------------
while read lines 

   do 
       check=FALSE
       while read lines_2 
         
           do
	        if ([ $lines = $lines_2 ]) then    # this is line 63
		
		check=TRUE
		break
		
		fi
		
           done < $3/only_hashes_right.log
   
     if ([ $check = FALSE ]) then
     
        echo $lines >> $3/singles_only_hashes.log
     
     fi
   
   done < $3/only_hashes_left.log
-----------------------snip------------------------------------

The logfiles just have hashes (of pdf-files) inside, created by md5sum.
Each of the 2 logfiles have some thousand of these hashes, one per line.
In the outer loop each hash is read from the first logfile and will be compared 
with each hash in the second logfile using the inner loop. If a "Partner" is
found, the inner loop breaks. If no Partner is found, this hash is printed in a
third logfile called singles_only_hashes.log, as you can see above.
I`m not sure if the check-variable is necessary, though.
With Suse this section and the whole script works properly, but not with bash
under cygwin with Windows XP. It creates following error message:

line 63: [: too many arguments

and this a thousand of times. I marked the corresponding line in the script
above. I also used as "shebang" this: #!/bin/bash instead of #!/bin/sh, 
but this didn`t solve the problem.

Could anybody point me to the right direction?

Any help is greatly appreciated.

Best regards, 

Axel Dreher





--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]