Linux Today: Linux News On Internet Time.

Collect User Input in a Bash Shell Script

Feb 02, 2011, 12:04 (0 Talkback[s])

[ Thanks to Andrew Weber for this link. ]

"The read command is designed to read and then use in the script input from the user. The input that is provided by the user is stored as a variable. This is a builtin variable that will store one line of input from the user in one or more variables. The read command is valuable as it is a major way to input information into a shell script. Lines are read into the script with standard input and split via the $IFS variable. This stands for internal field separator. The first word is assigned the first variable, the second word the second variable, etc.

Read options
-a name assign each work in an array of the name
-d delim use a deliminator to terminate input instead of new line
-e input from keyboard uses Readline Library, The Readline Library is a set of library routines that controls the way keys function when typing text at the command line."

Complete Story

Related Stories: