Re: read and REPLY
>>>>> "D" == Dale Scheetz <dwarf@polaris.net> writes:
D> I am very new to script writing so pardon my ignorance. I have been
D> working from the bash man page. It indicates that read (with no
D> parameters) puts the line read into the predefined variable
D> REPLY. My problem is that I don't seem to be able to *use* the
D> variable. With a line like: echo "$(REPLY)" or echo $(REPLY) I get
D> the error : REPLY command not found. If I try: echo REPLY the
D> output is just REPLY. How do I get the contents of reply?
That's because bash doesn't use () for delimiting variables. In bash,
parens (conceptually) start a subshell, so you can say (cd foo; ls)
and get a listing of foo without changing your current directory.
bash uses curly braces to delimit variable names, so what you meant to
say was ${REPLY} or you can drop them and use $REPLY when it's
unambiguous.
An example where braces are required would be
echo "${REPLY}somemessage"
--
Rob
Reply to: