Bourne shell programming question...

Kenneth Almquist ka at hou3c.UUCP
Tue May 15 04:21:09 AEST 1984


If you have the line(1) program, you can read a line from the
terminal by saying:

	a=`line < /dev/tty`

As you point out, it is also possible to use exec to redirect
the standard input (allowing you to use read).  You can move
stdin to a different file descriptor first if you will need it
later:
	exec 3<&0 </dev/tty	# open /dev/tty as stdin
	read a			# read a line from the terminal
	exec <&3 3<&-		# restore original standard input

Kenneth Almquist



More information about the Comp.unix mailing list