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

Re: Need some shell scripting help

begin  Dale Scheetz quotation:

> OK, we all know how easily I get confused, so lets see if I can explain my
> problem.
> Usually, when I want to work with a list of files I do something like:
> ls >aaa
> while read item
> do
> echo "${item}"
> done <aaa
> rm aaa
> The problem with this logic is that it requires a temporary file (aaa), so
> I've been trying to figure out the syntax that doesn't need the file. What
> I have so far, that sort of works is:
> while read item
> do
> echo "${item}"
> done <$(ls)

I usually do something like this:

   ls -1 --color=none | while read i ; do
           do-something-to "$i"

which ensures that you don't get tripped up by spaces in filenames,
although other metacharacters in filenames may cause hassle.

 /////////////////  |                  | The spark of a pin
<sneakums@zork.net> |  (require 'gnu)  | dropping, falling feather-like.
 \\\\\\\\\\\\\\\\\  |                  | There is too much noise.

Reply to: