Re: BASH no longer does 'for i in $(ls); do ls $i; done'??

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



On 05/19/2010 01:48 AM, Jan de Groot wrote:
> On Wed, 2010-05-19 at 01:41 -0500, David C. Rankin wrote:
>> So the bottom line is don't alias 'ls'. And, I guess, the next
>> question would
>> be, how or where can I safely customize the behavior of ls without
>> screwing
>> myself again. 
> 
> Solution is simple: don't use ls for the for loops you're doing. I just
> tested it on my system, the colored files and directories give "No such
> file or directory", which makes sense, as the variable contains ascii
> chars for color information.
> 
> I would suggest using globbing, why would you use for i in $(ls); while
> you can use for i in *;
> 
> 

Jan,

	Point well taken. I don't know how I fell into that trap. Globbing is the way
to go. I guess it was just more logical to do for i in (the list); and when
thinking about "What gives me 'the list'", the ls trap found another victim :p

-- 
David C. Rankin, J.D.,P.E.
Rankin Law Firm, PLLC
510 Ochiltree Street
Nacogdoches, Texas 75961
Telephone: (936) 715-9333
Facsimile: (936) 715-9339
www.rankinlawfirm.com


[Index of Archives]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]
  Powered by Linux