Skip to main content
Tweeted twitter.com/#!/StackUnix/status/637948173546299392
edited tags
Link
Gilles 'SO- stop being evil'
  • 866.1k
  • 205
  • 1.8k
  • 2.3k
edited title
Link
Michael Durrant
  • 43.8k
  • 73
  • 176
  • 238

How to add a header orand/or footer to a sed or awk stream?

added 264 characters in body
Source Link
Michael Durrant
  • 43.8k
  • 73
  • 176
  • 238

I have a bunch of output going through sed and awk.

How can I prefix the output with START and suffix the answer with END?

For example, if I have

All this code on all these lines and all these 

How could I get:

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

?

My attempt was:

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

but I got

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

I have a bunch of output going through sed and awk.

How can I prefix the output with START and suffix the answer with END?

For example, if I have

All this code on all these lines 

How could I get:

START All this code on all these lines END 

?

I have a bunch of output going through sed and awk.

How can I prefix the output with START and suffix the answer with END?

For example, if I have

All this code on all these lines and all these 

How could I get:

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

?

My attempt was:

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

but I got

... START All this code END START on all these lines END START and all these END 
Source Link
Michael Durrant
  • 43.8k
  • 73
  • 176
  • 238
Loading