May 2000
Beginner
761 pages
18h 20m
English
To make a script interactive, a special TC shell variable is used to read standard input into a variable. The $< symbol reads a word from standard input up to the first white space but not including the newline, and assigns the word to a variable. By placing $< in double quotes (or parentheses)[1], a whole line is read, not including the newline.
[1] The C shell does not rerquire double quotes around the $< variable to read a whole line.
(The Script - greeting) #!/bin/tcsh -f # The greeting script 1 echo -n "What is your name? " 2 set name = "$<" 3 echo Greetings to you, $name. (The Command Line) > chmod +x greeting > greeting 1 What is your name? Dan Savage 3 Greetings to you, ... |
Read now
Unlock full access