Get Header and Trailer record using a single sed command

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
RAJARP
Participant
Posts: 147
Joined: Thu Dec 06, 2007 6:46 am
Location: Chennai

Get Header and Trailer record using a single sed command

Post by RAJARP »

Hi ,

I have used sed command successfully in the Filter property of sequential file stage in the past
to get

Code: Select all

 sed -e '1d' -e '$d' 
--> all records without header and trailer

Code: Select all

 sed  '1!d'
--> just the header record

Code: Select all

sed  '$!d'
--> just the trailer record

But I want to get just the header and trailer using a same sed command
So far, I have tried

Code: Select all

  1.sed '1!d;$!d' 
   2.sed -e '1!d' -e '$!d' 

without any luck :oops:

Also, tried sed with -r flag as in sed -r and again no desired output.
Any pointers/help to achieve the same would be much appreciated



Thanks,
Raja
rkashyap
Premium Member
Premium Member
Posts: 532
Joined: Fri Dec 02, 2011 12:02 pm
Location: Richmond VA

Post by rkashyap »

In the Filter property enter either

Code: Select all

sed -n '1p;$p'
or

Code: Select all

awk 'NR==1;END{print}'
RAJARP
Participant
Posts: 147
Joined: Thu Dec 06, 2007 6:46 am
Location: Chennai

Post by RAJARP »

Thanks Kashyap,
Both of the commands worked like charm.Much appreciated :-)
Post Reply