Hello,
I am new to scripting.
How do I read multiple lines from the command line?
I know read reads one line, but if I have to read multiple lines, how should I do?
Thanks,
Prasanna
Hello,
I am new to scripting.
How do I read multiple lines from the command line?
I know read reads one line, but if I have to read multiple lines, how should I do?
Thanks,
Prasanna
Read a file:
data=$(< myfile.dat)
all of myfile.dat is now read in to the variable called "data"
Is that what you mean? If not, give an example of expected input and what you need to do with the output.
Thanks Jim.
I would like to read interactively from the shell in the middle of the script.
The shell should wait for the user to enter multiple lines, read and store it in a variable rather than reading from the file.
like how read var; would wait for the user to enter some text.
I want the shell to wait until the user finishes entering his input, till he presses Ctrl+D.
Thanks,
Prasanna
while read
do
S+="$REPLY
"
done
echo "$S"
text=$(cat)
echo "$text"