Appending data at the first and last line of a file

Hi,

Am trying to write a shell script which will append a header and a footer to an existing file. Header will contain details like the current date while the footer will contain the no: of records listed in the file.

I know we can use the CAT command, but i have no clue abt the syntax to append to the start and end of a file :confused: . Any help will be appreciated!

sed "1i\\
header info" file |
sed "$a\\
footer info" >tmp
mv tmp file
awk 'BEGIN{print "header"} {print} END {print "trailer"}' filename >tmpfile
mv tmpfile filename

awk 'BEGIN {system("date")} {print} END { print "No of records -",NR}' filename >tmpfile

{
  print "This is the header"
  cat file
  print "This is the footer"
} > file.new