文字列を別の単語に分割

文字列を別の単語に分割

bashシェルと同様に、echoを使用して文字列を印刷できますecho "This is a sample string"

パイプとして使用できるいくつかのコマンドまたは文字列の後にエコーされるいくつかのパラメータがありますか?これにより、次のような結果が出力されます。

This
is
a
sample
string

デフォルトでは、文字列を分割し、各単語を新しい行に印刷します。

ベストアンサー1

$ echo "This is a * sample string" | tr ' ' '\n'
This
is
a
*
sample
string
$ 

おすすめ記事