delorie.com/archives/browse.cgi | search |
X-Recipient: | archive-cygwin AT delorie DOT com |
DomainKey-Signature: | a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id |
:list-unsubscribe:list-subscribe:list-archive:list-post | |
:list-help:sender:mime-version:in-reply-to:references:date | |
:message-id:subject:from:to:content-type; q=dns; s=default; b=y1 | |
ZHrKwZD6Kqw+6ey1ZHYZL2eiRMj5cX/WuGVO/6Uj1KK9eG3xZQ/6zMFcdLFP+Bzj | |
qotRYQ7+jTqscvxUglzc92hYoshy8UraNuTDv+/VVCsf57DxfE3BDP3go3EaMzxe | |
FR/Hlug/WfDzjck4u+hORmooxSJ9yUuS39fNdnmFA= | |
DKIM-Signature: | v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id |
:list-unsubscribe:list-subscribe:list-archive:list-post | |
:list-help:sender:mime-version:in-reply-to:references:date | |
:message-id:subject:from:to:content-type; s=default; bh=HQMCZCA4 | |
2jEatum6hDEfmMjjmDU=; b=njlB+KWvmSuQpEmFJjvV9X8sBXOpr3MNKeHR4T+h | |
sESExyi0xmwpJS3J0a6BllRiGjjprWyF6JKEN6uGaw9L8mf/nXwM3MBas4OuTo5N | |
wczvpNpk3brvvtcKuD5gQ1lB89y5KjmaAV6P/Fd8elfrRDnumYlpKze66s+mSmd3 | |
ThM= | |
Mailing-List: | contact cygwin-help AT cygwin DOT com; run by ezmlm |
List-Id: | <cygwin.cygwin.com> |
List-Subscribe: | <mailto:cygwin-subscribe AT cygwin DOT com> |
List-Archive: | <http://sourceware.org/ml/cygwin/> |
List-Post: | <mailto:cygwin AT cygwin DOT com> |
List-Help: | <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs> |
Sender: | cygwin-owner AT cygwin DOT com |
Mail-Followup-To: | cygwin AT cygwin DOT com |
Delivered-To: | mailing list cygwin AT cygwin DOT com |
Authentication-Results: | sourceware.org; auth=none |
X-Virus-Found: | No |
X-Spam-SWARE-Status: | No, score=-0.5 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 |
X-HELO: | mail-lb0-f169.google.com |
MIME-Version: | 1.0 |
X-Received: | by 10.112.29.175 with SMTP id l15mr1038066lbh.39.1413366061975; Wed, 15 Oct 2014 02:41:01 -0700 (PDT) |
In-Reply-To: | <543D8D84.5050302@molconn.com> |
References: | <5439C59F DOT 5060308 AT molconn DOT com> <5439C8A6 DOT 5020605 AT cornell DOT edu> <5439CB8F DOT 9000708 AT molconn DOT com> <m1dedl$mea$1 AT ger DOT gmane DOT org> <543D8D84 DOT 5050302 AT molconn DOT com> |
Date: | Wed, 15 Oct 2014 11:41:01 +0200 |
Message-ID: | <CAM9pMnOqbfRQvLiNb0Ea7JpnA5Y09tRteXAmyF4OH_n=Ce8=QQ@mail.gmail.com> |
Subject: | Re: cygwin bash script suddenly can't find ls, grep |
From: | Robert Klemme <shortcutter AT googlemail DOT com> |
To: | cygwin <cygwin AT cygwin DOT com> |
X-IsSubscribed: | yes |
On Tue, Oct 14, 2014 at 10:54 PM, LMH <lmh_users-groups AT molconn DOT com> wrote: > Thorsten Kampe wrote: >> * LMH (Sat, 11 Oct 2014 20:30:07 -0400) >>> Good Lord, I guess I wasn't thinking very clearly trying to use >>> PATH as >>> a variable for something else. I changed to, >>> >>> FILE_DIR=$(ls -d './'$SET'/'$FOLD'/'$FOLD'_anneal/'$PARAM_SET'/'$AN_SET) >>> echo $FILE_DIR >>> >>> FILE_LIST=($(ls $FILE_DIR'/'*'out.txt' )) >>> echo ${FILE_LIST[@]} >> >> That looks pretty ugly. You probably can replace all that with >> >> FILE_LIST=(./$SET/$FOLD/$FOLD_anneal/$PARAM_SET/$AN_SET/*out.txt) More suggestions: 1. use lowercase variable names for variables used only inside your script. Since variable names are case insensitive it will avoid collisions like this and also improve readability of the code. 2. In bash you can set shell option "nullglob" to avoid a one element array with the glob pattern if there is no matching file. In zsh it's "setopt NULL_GLOB" I believe. 3. Since we do not know whether there are spaces in variables I would replace the line above with (including suggestion 1): file_list=("$set/$fold/$fold_anneal/$param_set/$an_set"/*out.txt) Kind regards robert -- [guy, jim].each {|him| remember.him do |as, often| as.you_can - without end} http://blog.rubybestpractices.com/ -- Problem reports: http://cygwin.com/problems.html FAQ: http://cygwin.com/faq/ Documentation: http://cygwin.com/docs.html Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |