awkでは印刷が機能しますが、echoが機能しないのはなぜですか?

awkでは印刷が機能しますが、echoが機能しないのはなぜですか?

それらを追加してください。

これは働きます:

awk 'BEGIN { FS=":"; }
{ print  $1  $3  $5; }' /etc/passwd

しかし、そうではありません:

awk 'BEGIN { FS=":"; }
{ echo  $1  $3  $5; }' /etc/passwd

理由を知りたいです。

ベストアンサー1

実行構造awkは次のとおりです。pattern { action statements }

作業
    作業文は中括弧{と}で囲まれています。作業文は、ほとんどの言語で一般的に使用される割り当て文、条件文、およびループ文で構成されています。使用可能な演算子、制御ステートメント、入力/出力ステートメントは、Cのパターンに従って設計されています。

  • printI/O ドアですawk

    マンページから:

    print                 Print the current record.  The output record is terminated with the value of ORS.
    
  • 入場マニュアル>印刷仕様:

    明細書の印刷

    単純で標準化された形式で出力を生成するには、printステートメントを使用してください。印刷する文字列または数字のみをカンマ区切りリストとして指定します。これは、単一のスペースで区切られ、その後に改行文字が続く出力です。ステートメントは次のとおりです。

    print item1, item2, …
    

詳細については、ご覧くださいman awk

また注:

PATTERNS AND ACTIONS
       AWK is a line-oriented language.  The pattern comes  first,  and  then  the  action.   Action  statements  are
       enclosed  in  {  and  }.  Either the pattern may be missing, or the action may be missing, but, of course, not
       both.  If the pattern is missing, the action is executed for every single record of input.  A  missing  action
       is equivalent to

              { print }

       which prints the entire record.

awkechoキーワード/文がありません。

$ man awk | grep echo | wc -l
0

おすすめ記事