![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Read a file line by line | VENC22 | UNIX for Dummies Questions & Answers | 4 | 10-30-2008 11:09 AM |
| Read logline line by line with awk/sed | dejavu88 | Shell Programming and Scripting | 7 | 05-26-2008 08:44 PM |
| read the file line by line | kittusri9 | Shell Programming and Scripting | 3 | 04-24-2008 08:26 AM |
| Read line by line from a variable. | sathishkmrv | Shell Programming and Scripting | 9 | 09-13-2007 10:25 AM |
| How to read from a file line by line and do stuff | spaceship | Shell Programming and Scripting | 4 | 03-17-2005 09:47 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Read one line from stdin
Hello,
I am Read one line from stdin stdin is the keyboard unless input redirection used Read one line from stdin, store line in a variable read variable_name Ask the user if he wants to exit the script Store the following in a file named read.sh and execute it Code:
#!/bin/sh # Shows how to read a line from stdin echo "Would you like to exit this script now?" read answer if [ "$answer" = y ] then echo "Exiting..." exit 0 fi Code:
Owner@YOUR-787F71A704 ~ $ sh read.sh Would you like to exit this script now? y read.sh: line 5: [y: command not found Thanks |
|
||||
|
if test "$answer" = "y"
then .... fi from the error it sounds like you actually missed the space between [ and ". Note, [ is often a link to test, it is useful to know that [ is just a program. |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|