The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #6 (permalink)  
Old 08-14-2007
matrixmadhan matrixmadhan is offline Forum Advisor  
Technorati Master
  
 

Join Date: Mar 2005
Location: leaf node in B+ tree
Posts: 2,953
There has been another thread as lorcan said and this seems to be only a continuation of the above thread in a new post.

Please continue to post your question in the same thread so that it would be easier to follow up rather than starting a new thread for the same question.

Assuming I have understood your requirement try this,

Code:
awk ' { if ( NR == 1 ) { head=$0 } else { last = $0 } arr[i++]=$0; }END{ printf "Header is : %s Trailer is : %s\n", head, last; for( x=0; x<i-1; x++) { print arr[x] } }' filename
Code:
Header is : header Trailer is : trailer
header
record 1
record 2
record 3
combined header and trailer is available followed by that
header is available
all the records are displayed
trailer record is not displayed

If this is not what you had asked for, let us know