how to call awk in a csh Program

Hi Friends,
Could you pleas help me out..

I have an awk program which works fine while running it in the command prompt.
The awk program is

awk 'BEGIN {
format="head -%d M2_Sales_N01.txt |tail -%d >M2_Sales_N01_%02d.txt\n"
n=0
m=0
}
{
if (n==0)
{
tmp=$1
n=1
}
else
{
res=$1-tmp
tmp=$1
m=m+1
printf(format,$1,res,m)
}
}' M2_Sales_N01_count.txt >>M2_Sales_N01.csh

But mu requiremnt is to put this awk in a shell scripts ,let say xyz.csh
and then exexcute the xyz.csh.

I put the syntax of awk in xyz.csh. But when i do
$ csh xyz.csh
Following error is comming
$ csh xyz.csh
Unmatched '

Friends please help me..
Thanks in advance

Friends,
Kindly help me out!!

Frinds..
Pllllllllllllllllz helpme out.

  1. You should not bump posts to get attention, pllllllllz.
  2. You should not be using csh as a scripting shell. It blows.
  3. You should not use a different shell on the command line when testing code for a shell script...the shells are not the same.
  4. You must escape each EOL in csh, which does not support multi-line quoted values without them, i.e.,
# BAD
echo '123
456'

# GOOD
echo '123\
456'

Hi Gus2000,
Accroding to you , I have put / in the last of each line . Still It doesnot wotrk and coming with same error.

I have done the following way
created one abc.csh

awk 'BEGIN {\
format="head -%d M2_Sales_N01.txt |tail -%d >M2_Sales_N01_%02d.txt\n"\
n=0\
m=0\
}\
{\
if (n==0)\
{\
tmp=$1\
n=1\
}\
else\
{\
res=$1-tmp\
tmp=$1\
m=m+1\
printf(format,$1,res,m)\
}\
}' M2_Sales_N01_count.txt >>M2_Sales_N01.csh

$$ csh abc.csh
Unmatched '

Please suggest me how to over come this.

I did make a suggestion..."don't use csh".

I even tried this and didn't get the error, so you either have whitespace after one or more backslashes (which defeats them) or your version of csh is even crappier than mine.