It is currently Tue, 07 Dec 2021 03:41:01 GMT



 
Author Message
 Reading a script file line by line.

Hello,

        How do I read a flat text file?

        I have a flat text file with one word on each line. I want to read each
line, one at a time, and do something with the word that I read.

        I don't do a lot of script programming so I'm unfamiliar with it all.

        An help, especially examples, would be greatly appreciated.

Thanks in advance

Lyndon F. Bartels
bart...@a1.western.tec.wi.us



 Fri, 02 Apr 1999 03:00:00 GMT   
 Reading a script file line by line.

:       I have a flat text file with one word on each line. I want to read each
: line, one at a time, and do something with the word that I read.

This should do:

#!/bin/ksh
# kshcat: cat in Korn shell
# This does not handle spaces and tabs as a `cat' should.

[ $# -eq 0 ] && {
print I need at least one argument.
exit 1

for i in $@
do
        while read x
        do
                print $x
        done<${i}
done

exit 0
# eof

-- Yiorgos Adamopoulos, <Y.Adamopou...@noc.ntua.gr>



 Fri, 02 Apr 1999 03:00:00 GMT   
 
   [ 2 post ] 

Similar Threads

1. read a file line by line in csh script

2. ksh script --reading file line by line?

3. read from stdin while reading line by line a file

4. line by line reading of the lines in list

5. Using read within a loop that parses a file line by line

6. reading files line-be-line?

7. Read a file line after line

8. reading line by line from a file

9. reading a file line by line

10. read a file line by line


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