Source From Here
Question
How can I output a multipline string in Bash without using multiple echo calls like so:
I'm looking for a portable way to do this, using only Bash builtins.
How-To
Here documents are often used for this purpose.
They are supported in all Bourne-derived shells including all versions of Bash. Another way is using bash built-in command
read:
Question
How can I output a multipline string in Bash without using multiple echo calls like so:
- echo "usage: up [--level
| -n ][--help][--version]" - echo
- echo "Report bugs to: "
- echo "up home page: "
How-To
Here documents are often used for this purpose.
- cat << EOF
- usage: up [--level
| -n ][--help][--version] - Report bugs to:
- up home page:
- EOF
- # -d DELIM : The first character of DELIM is used to terminate the input line, rather than newline.
- read -d '' help <<- EOF
- usage: up [--level
| -n ][--help][--version] - Report bugs to:
- up home page:
- EOF
- echo "$help"
This message was edited 3 times. Last update was at 15/10/2016 12:23:02
沒有留言:
張貼留言