It is currently Thu, 20 Jan 2022 05:22:23 GMT



 
Author Message
 Bourne Shell Script Question
I have a text file in the following format...

john 1 2 3
mary 4 5 10
etc,etc

From a bourne shell script I want to read a line of the file into $variable
until EOF is reached, as in...

while ! EOF
do
    get a line
    parse and process the line
done

What I dont know is how do you read each line from file
How do you know when eof is reached (I suppose I could
use wc -l first so I know how many lines but is there a neater way ?)

Solaris 2.6



 Fri, 10 Jan 2003 03:00:00 GMT   
 Bourne Shell Script Question

(while read name n1 n2 n3; do echo $name $n1 $n2 $n3; done) < file

Read sh man page for details.

--
andrei



 Fri, 10 Jan 2003 03:00:00 GMT   
 Bourne Shell Script Question

while read VARIABLE
do
        yadda yadda
done

--
Brandon Hume    - hume -> BOFH.Halifax.NS.Ca, http://WWW.BOFH.Halifax.NS.Ca/
                       -> Solaris Snob and general NOCMonkey



 Fri, 10 Jan 2003 03:00:00 GMT   
 Bourne Shell Script Question
You don't have to worry about the end of the file.

cat filename | while read a b c d
do
   < do something with $a $b $c and $d >
done



 Sat, 11 Jan 2003 03:00:00 GMT   
 Bourne Shell Script Question
In article <397DCC02.F86ED...@lucent.com>,
  "James A. Williams" <jawilli...@lucent.com> wrote:

Can I claim to be the first to give this week's "pointless use of 'cat'"
award? :-)

--
Tony

Sent via Deja.com http://www.deja.com/
Before you buy.



 Sun, 12 Jan 2003 03:00:00 GMT   
 Bourne Shell Script Question

Cats are, by definition, pointless. ;-)
--
Willard Francis Otto Dawson      +1 770 814 5099 / +1 770 814 5202 FAX
Siemens Business Services, ENS   mailto:willard.daw...@sbs.siemens.com
4570 River Green Pkwy, Ste 140   http://www.sbs.siemens.com/
Duluth, GA  30096-2564           Standard disclaimer applies.



 Sun, 12 Jan 2003 03:00:00 GMT   
 
   [ 6 post ] 

Similar Threads

1. A Solaris 8 (Bourne Shell) Scripting question, regarding a log rotation script

2. bourne shell script question re: for-in loop

3. Simple Bourne Shell script question

4. Bourne Shell Script Question

5. Bourne Shell Script question......

6. Bourne Shell script question

7. bc in bourne shell script question

8. Date conversion in Bourne shell script question

9. Simple Bourne Shell script question


 
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software