[Techtalk] copy file headers...

Hamster hamster at hamsternet.org
Fri May 17 16:34:26 EST 2002


>Is there any way to copy _x_ number of lines
>from the header of one file over the header of
>another file?


Yes, I can think of several ways, though I am sure there are countless others. It depends on how complex you want to get and if its just a one-off command or something you want to script.
 
You really only need the command sed, but depending on how complex the two files are, there are easy ways and tricky ways of doing it.

If its always going to be the first x lines (ie line 1 through to x) then you can use:

sed to replace lines 1 through x of file2 with the output of the command "head x" performed on file1.

Where:
file1 contains the headers you want to use
file2 contains the headers you want to discard/replace

If you want help writing the actual command, or want to script in some way using variables to control the value of x, write back with more detail, I'm happy to help.

Hamster







More information about the Techtalk mailing list