13

列の行を正しく並べるために 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
4

3 に答える 3

26

catはこれに使用するのが好きです:

使用法.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

これは出力されます:

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
于 2013-10-22T03:11:54.880 に答える