To print the Header and trailer in one line with 300 char each. Removal of header and trailer line. Use the below
Just a flavour to matrixmadhan's command as per your req
Code:
awk ' { if ( NR == 1 ) { head=substr($0,1,300);} else { last = substr($0,1,300);} arr[i++]=$0; }END{ printf "Header is : %-300s Trailer is : %-300s\n", head, last; for( x=1; x<i-1; x++) { print arr[x] } }' filename