In general, calling cat with just one argument is a useless use of cat. Instead of running cat 3 times, just do:
cat header datafile footer > file1.txt
That's a bit more optimized than your way.
Beyond that, no; there's no UNIX system call to insert data before other data in a file, and I don't know a system that does. Nor is there a faster form of read() than the general purpose one, why would anyone ever use the "slow" one?
If whatever's using these datafiles can accept input on stdin, you could generate them at runtime to avoid the extra reads and wasted storage:
my data file is having around 20 millions of records, it is a fixed width format file.
Now I want to create Header and trailer like this...
Hcurrentdate" "
data" "
data" "
T0000004" "
Header will start with letter 'H' followed by currentdate, followed by 20 spaces.
Then data records will come with same length
Trailer record will start with 'T', number of records in file(including header&trailer) in 10 length filed, followed by 20 spaces.
Please suggest me how to implement all this logic in script?