linux - How to pass variable within printf -
i trying echo variable within printf. first prompt user input using command below
printf 'specify lrus [default 128]: ' ;read -r lrus
next prompts user again see if wants input used previous question:
printf 'are sure want $lrus lrus: ' ;read -r ans
for example output below:
specify lrus [default 128]: 60 sure want 60 lrus: yes
the above output trying achieve allowing pass previous input variable next question using printf.
your problem using single-quotes. parameters not expanded within single quotes.
parameters expanded in double-quotes, though:
printf "are sure want $lrus lrus: "
note there's no need separate print; it's better use -p
argument read
(that understands terminal width, 1 thing):
read -p "specify lrus [default 128]: " -r lrus read -p "are sure want $lrus lrus? " -r ans
Comments
Post a Comment