sedまたはawkストリームにヘッダーおよび/またはフッターを追加するには?

sedまたはawkストリームにヘッダーおよび/またはフッターを追加するには?

sedとawkを介して多くの出力があります。

出力にSTARTプレフィックスを追加し、答えにENDサフィックスを追加する方法は?

たとえば、私が持っている場合

All this code
on all these lines
and all these

どうやって入手できますか?

START
All this code
on all these lines
and all these
END

私の試みは次のとおりです

awk '{print "START";print;print "END"}'

しかし、私は得た。

...
START
    All this code
END
START
    on all these lines
END
START
    and all these
END

ベストアンサー1

これは図のように動作しますジェイソン・ライアン:

awk 'BEGIN{print "START"}; {print}; END{print "END"}'

おすすめ記事