wget -qO-に関する質問

wget -qO-に関する質問

文字列として

wget -qO-

一体私が何をしているの?ダッシュのあるスイッチを見たことがありません。後ろに表現方式。

しかし、Dockerをインストールするには、以下を使用しています。wget -qO- https://get.docker.com | sh

答え1

これには間違ったことも奇妙なこともありません。

-qO--q(quiet)の後に-O -(stdoutとして出力)と同じです.

バラよりwget手動

実際、オプションを一緒に圧縮するのは一般的な Unix 慣行であり、オプション引数を使用するオプションには通常、中間スペースは必要ありません。

sh実際、ネットワークから何かを抽出して直接入力することにもっと注意を払う必要があります。

答え2

以下はコマンドwgetcurl同じ効果があります。

wget -q -O - https://download.docker.com/linux/ubuntu/gpg

curl -fsSL https://download.docker.com/linux/ubuntu/gpg

Linux端末で実行して結果を確認できます。デフォルトではシステム未処理ストリームに出力されます。

これらのコマンドの実際の例の1つは、| apt-key add -apt-keyを追加することです。

例えば、

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add -

答え3

これは次のとおりです。

wget -q -O -

ここでのman wget各オプションの意味は次のとおりです。

-q
--quiet
    Turn of Wget's output.

-O file
--output-document=file
    The documents will not be written to the appropriate files, but all will be concatenated together and written to file.

説明を続けると、-Oミステリーは標準出力を表示するためにオプションで使用される特別なシンボルにすぎない-ことがわかります。-O

If ‘-’ is used as file, documents will be printed to standard output, disabling link conversion.

関連情報