read from stdin while reading line by line a file

read from stdin while reading line by line a file

Post by Matias Wolosk » Tue, 04 May 2004 03:00:47



while read line ; do
    // I need to read input from the user
    read INPUT
done < file.txt

the problem is that it is not going through "read INPUT"

any workaround?

thanks for all your help. I really appreciate it
matias

 
 
 

read from stdin while reading line by line a file

Post by Chris F.A. Johnso » Tue, 04 May 2004 03:34:03



Quote:> while read line ; do
>     // I need to read input from the user
>     read INPUT
> done < file.txt

> the problem is that it is not going through "read INPUT"

> any workaround?

read INPUT < /dev/tty

--
    Chris F.A. Johnson                  http://cfaj.freeshell.org/shell
    ===================================================================
    My code (if any) in this post is copyright 2004, Chris F.A. Johnson
    and may be copied under the terms of the GNU General Public License

 
 
 

read from stdin while reading line by line a file

Post by Barry Margoli » Tue, 04 May 2004 04:21:58




Quote:> while read line ; do
>     // I need to read input from the user
>     read INPUT
> done < file.txt

> the problem is that it is not going through "read INPUT"

> any workaround?

> thanks for all your help. I really appreciate it
> matias

exec 3<&0
while read line; do
  read -u 3 INPUT
done < file.txt

or:

while read -u 3 line; do
  read INPUT
done 3< file.txt

If your shell's read command doesn't have the -u option to specify a
file descriptor to read from, change it to:

  read whatever 0<&3

--

Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***

 
 
 

read from stdin while reading line by line a file

Post by Kevin Colli » Wed, 05 May 2004 01:36:09



> while read line ; do
>     // I need to read input from the user
>     read INPUT
> done < file.txt

-SNIP-

What shell are you using that supports '//' as a comment?  Maybe the c++ shell?

:)

Kevin

 
 
 

1. line by line reading of the lines in list

Hi,

I want to read the list line by line and then want to compare these line
with filenames in the directory. When I use FOR loop it does it, but I am
not able to get the required result.

e.g.

linelist="          ###need to find files with these names in dir1 e.g.
file1=aaaaaaaaaa
aaaaaaaaaa
bbbbbbbbb
cccccccccc"

### dir1 consists of only two files called first, third
for lines in $linelist ; do

done

# I tried several combinations, so may the code above may not be completely
correct in syntax at this moment.

The output (foundfiles) from this is:
aaaaaaaaaa
cccccccccc

But, I want:
aaaaaaaaaa
            ### leaving this line blank because "bbbbbbbbbb" file was not
present in the directory
cccccccccc

Many thanks for your help

2. SBlaster 16 SCSI 3xCDROM (NEC)

3. line by line without using echo "$i" | while read line?

4. HD write_intr error

5. How to read line by line of a file

6. Xconfig Warning

7. HELP: How do I read a file line-by-line without getting spaces stripped?

8. Problems detecting 3Com 3c509B Eitherlink III card.

9. read a file line by line

10. How to read line by line from a file?

11. Read a file line after line

12. reading files line-be-line?

13. Line by line file read