urgent help needed regarding splitting file

how can i split a file on last record ? say i have a file A with 4 records as follows :

first line
second line
third line
last line

I want to make two files B and C

with contents of B as
first line
second line
third line

and the contents of C as
last line

Try this,

sed -n '$!p' A > B ; sed -n '$p' A > C

You try this.

sed -n '$!p' A > B (or) sed '$d' A > B
sed '$!d' A > C (or) sed -n '$p' A > C

You can use the following commands also

head -n 3 A > B

Now the B file will contain

first line
second line
third line

tail -n 1 A > C

Now the C file will contain

last line

Thillai,your second approach which is to copy the last line of a file into C is OK.But,the first command has to be like this.Because,we can't sure that there are only four lines in a file.

head -n -1 A > B

Good try. But Here the user mentioned that there are 4 records only in the file A.
Kindly refer that.

Try the following line,

sed '$d' A > B ; sed '$!d' A > C

B file contents:
--------------------
first line
second line
third line

C file content:
-------------------
last line

He has given it for an example thillai.Kindly make a note of it.

With one Awk, get two files output.

awk 'NR==FNR{sum++} NR>FNR {if (FNR<sum) {print $0 > "B"} else {print $0 > "C"}}' A A

$ cat B
first line
second line
third line

$ cat C
last line