|
From: | Matthew Woehlke |
Subject: | Re: Puzzling discrepancy in bash variables |
Date: | Wed, 15 Oct 2008 19:08:46 -0500 |
User-agent: | Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.8.1.16) Gecko/20080723 Fedora/2.0.0.16-1.fc9 Thunderbird/2.0.0.16 Mnenhy/0.7.5.0 |
RMMM wrote:
RMMM wrote:As far as I can tell, the variables $filenames and $filenames1 have thesame values. Yet, they behave differently when used in an argument. Is there some hidden aspect to a bash variable that I'm not seeing?I just figured out the problem. I was running this in a shell with dircolors. Arggg!doing filenames=`ls --color=no mydir`is all I needed to do. Well ... maybe there's some better way of getting the filenames that's immune to any invisible codes.
Guess 1: command ls # avoids aliases, I think? \ls # similar env ls # also similar(note: I belive --color=no is default behavior, probably you have an alias that is adding --color=auto / --color=tty, which is why avoiding the alias should work)
Guess 2: files="$( for f in mydir/* ; do echo -n "${f#mydir/} " ; done )" # uses bash glob expansion instead of ls, probably faster to boot Guess 3: files="$( cd mydir ; echo * )" -- Matthew Please do not quote my e-mail address unobfuscated in message bodies. --Time is an illusion. Lunchtime doubly so. -- Ford Prefect (Douglas Adams' HHGttG)
[Prev in Thread] | Current Thread | [Next in Thread] |