LINUX.IE, website of the Irish Linux Users' Group
Tux rules!

   
Home
New Users
Articles
Download
Projects
Community
Vendors

  Print Version
Email to...
 
Archives:


planetILUG

Recent News

News Archive


Join the
ILUG
on FaceBook


Join the
ILUG
on LinkedIn


Join the
ILUG SETI
Group



















 
 :: Mailing Lists

[ILUG] Spaces in arguments in a bash for loop

[ILUG] Spaces in arguments in a bash for loop

John Gill bmrg at gofree.indigo.ie
Sat Nov 4 12:28:14 GMT 2000


> On Sat, Nov 04, 2000 at 09:15:40AM +0000, John Gill wrote:
> 
> > Another way round this is to use read.  Try something like this:
> > 
> > grep ding fonts | grep -v TT | while  read line; do
> >   echo "$line"
> > done
> 
> Excellent answer John ! To my mind, it has the benefit of being a little
> neater than the solution using IFS, less typing (only two keystrokes more
> than my original non-working for loop solution - I checked :-) ), and just
> somehow handier to use on the fly, which is how I usually do these things.
> 
 
Of course you can save another 6 key strokes with:

grep ding fonts | grep -v TT | while  read l; do
  echo "$l"
done

Setting IFS is fine.. until you forget you've set it to 
something weird.

John





More information about the ILUG mailing list
Read this without the formatting.
                                                                                                    

 

Hosted by HEAnet


Maintained by the ILUG website team. The aim of Linux.ie is to support and help commercial and private users of Linux in Ireland. You can display ILUG news in your own webpages, read backend information to find out how. Networking services kindly provided by HEAnet, server kindly donated by Dell. Linux is a trademark of Linus Torvalds, used with permission. No penguins were harmed in the production or maintenance of this highly praised website. Looking for the Indian Linux Users' Group? Try here. If you've read all this and aren't a lawyer: you should be!
RSS Version
Powered by Dell