Bash脚本"用法"输出格式

fla*_*diu 12 bash scripting formatting

输出bash脚本的帮助文本以使列线正确排列的好方法是什么?

就像是:

 Usage: mycommand [options]

    -h| --help           this is some help text.
                         this is more help text.
    -1|--first-option    this is my first option
    -2|--second-option   this is my second option
Run Code Online (Sandbox Code Playgroud)

imp*_*p25 23

我喜欢用cat这个:

usage.sh:

#!/bin/bash

cat <<EOF
Usage: $0 [options]

-h| --help           this is some help text.
                     this is more help text.
-1|--first-option    this is my first option
-2|--second-option   this is my second option
EOF
Run Code Online (Sandbox Code Playgroud)

这将输出:

Usage: usage.sh [options]

-h| --help           this is some help text.
                     this is more help text.
-1|--first-option    this is my first option
-2|--second-option   this is my second option
Run Code Online (Sandbox Code Playgroud)