例如:
read -p $'Please Enter the percent [30 between 100]\x0a The value is Default = 80 :' scale_percent
we use above syntax to insert hex values, we insert \x0a
which is the hexadecimal value of the newline character (LF). You can use same syntax above with echo
to produce new lines, eg:
echo $'One line\x0asecond line'
This is a feature of BASH 2, it is documented here, the $''
is used to translate all escape sequences inside it for its ascii transcription. So we could obtain the same result of example above, this way:
echo $'One line\nsecond line'
注意要用单引号