Debian Codegraph @

read-r.sh

raw symbols SCIP
1 #!/bin/bash
2
3 echo
4
5 echo "Enter a string terminated by a \\, then press <ENTER>."
6 echo "Then, enter a second string (no \\ this time), and again press <ENTER>."
7
8 read var1 # The "\" suppresses the newline, when reading $var1.
9 # first line \
10 # second line
11
12 echo "var1 = $var1"
13 # var1 = first line second line
14
15 # For each line terminated by a "\"
16 #+ you get a prompt on the next line to continue feeding characters into var1.
17
18 echo; echo
19
20 echo "Enter another string terminated by a \\ , then press <ENTER>."
21 read -r var2 # The -r option causes the "\" to be read literally.
22 # first line \
23
24 echo "var2 = $var2"
25 # var2 = first line \
26
27 # Data entry terminates with the first <ENTER>.
28
29 echo
30
31 exit 0