Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

STDIN 1

Status
Not open for further replies.
Aug 30, 2001
58
US
how do you do a standard input prompt with a shell script?
 
It probably depends on your shell, but this works in /bin/sh:

echo -n "Enter something: "
read ans
echo "You just typed $ans"

I don't think the "-n" is standard.
 
Yeah, do "man echo".

The command /usr/bin/echo DOES do -n, as well as the builtin echo of csh, but ksh does not, Bourne does...

gene
 

yeah, if echo -n doesn't work, use a \c to suppress the carriage return.

gene
 
or use

printf "Enter something: "
read answer

if you have printf

HTH,

p5wizard
 
And in ksh:
read ans?"Enter something: "
echo "You just typed $ans"

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top