X-Spam-Check-By: sourceware.org Date: Thu, 22 Jun 2006 09:42:43 -0400 (EDT) From: Igor Peshansky Reply-To: cygwin AT cygwin DOT com To: ydubost cc: cygwin AT cygwin DOT com Subject: Re: Pb with bash script under cygwin In-Reply-To: <4993126.post@talk.nabble.com> Message-ID: References: <4934908 DOT post AT talk DOT nabble DOT com> <4993126 DOT post AT talk DOT nabble DOT com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com On Thu, 22 Jun 2006, ydubost wrote: > Hello, > > Thank you for all your suggestions. > I have finally managed to do what I wanted. > > There was several reasons: > 1) the different -name options of find have to be enclosed in protected > bracket \( ... \) > 3) the need to use the eval function > 2) in a script, one need to protect the different special characters from > being interpreted before the final command. For exemple, I have to > write \\\( in order to obtain \(. I suspect that learning about single vs. double quoting, and bash arrays, would have saved you a lot of grief. > The problem, is that I don't really understand what happens, why I nedd to > put 3\ and not 2 or 4, but the main point is that it now works. The paired-up backslashes produce one escaped backslash. The last one escapes the parenthesis. > my new script is : > > TYPELIST="._bc ._ch ._cl ._cm ._df ._dl ._ev ._fl ._gr ._hl ._is ._mb ._mm > ._mp ._ov ._pr ._sn ._sy ._ti ._tr ._sf" > > Extension=$(echo ${TYPELIST} | sed -e"s:[ ][.]:' -delete \\\) -o \\\( -iname '*.:g" | sed -e"s:^[.]:\\\( -iname '*.:" | sed -e"s:$:' -delete \\\):") Oh, and learning about sed would help too. In particular, you can do all of the above in one expression. Incidentally, you can also do this all in bash, without spawning the sed processes... > MaCommande="find . ${Extension}" > > eval ${MaCommande} ...and you need quotes here too, i.e., eval "${MaCommande}" HTH, Igor -- http://cs.nyu.edu/~pechtcha/ |\ _,,,---,,_ pechtcha AT cs DOT nyu DOT edu | igor AT watson DOT ibm DOT com ZZZzz /,`.-'`' -. ;-;;,_ Igor Peshansky, Ph.D. (name changed!) |,4- ) )-,_. ,\ ( `'-' old name: Igor Pechtchanski '---''(_/--' `-'\_) fL a.k.a JaguaR-R-R-r-r-r-.-.-. Meow! "Las! je suis sot... -Mais non, tu ne l'es pas, puisque tu t'en rends compte." "But no -- you are no fool; you call yourself a fool, there's proof enough in that!" -- Rostand, "Cyrano de Bergerac" -- 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/