FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Ubuntu > Ubuntu User

 
 
LinkBack Thread Tools
 
Old 12-01-2009, 08:40 AM
Ray Parrish
 
Default Reading a variable line by line with while loop

Hello,

I have been using while loops to read files in line by line when I want
to process things on a line oriented basis. Sometimes i have the set of
lines I want to read through already in a variable, and have to write
them to file before beginning to read line by line.

I was wondering if it is possible to read a variable line by line
somehow with a while loop? Would it possibly be faster than using a file
to read from?

I was thinking something along the lines of the following code might
work, but have not tested it yet.

while read ThisLine; do
# process each line
echo "$ThisLine"
done < `echo "$Variable"`

Is this something that might work, and would it be more efficient than
writing to, and reading from a file? Is there some other way I've missed
to make it work?

Thanks for any help you can be.

Later, Ray Parrish

--
The Future of Technology.
http://www.rayslinks.com/The%20Future%20of%20Technology.html
Ray's Links, a variety of links to usefull things, and articles by Ray.
http://www.rayslinks.com
Writings of "The" Schizophrenic, what it's like to be a schizo, and other
things, including my poetry.
http://www.writingsoftheschizophrenic.com



--
ubuntu-users mailing list
ubuntu-users@lists.ubuntu.com
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
 

Thread Tools




All times are GMT. The time now is 12:54 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org