script to take row count

hi

i am pretty new to unix .i am ETL guy
I need a unix script to take row count of a file and write it to another file
the problem with wc-l is it include filename also
wc -l abc.dat
will give me like 1000 abc.dat
i just want 1000 to be written
can u just take 2 min to write a simple script for me

You don't need a script for that:

awk 'END{print NR}' file > new.file

thank buddy u r great

Hi Danmero,

I have used the following command to count the rows. It works fine for small file which has column sort.
awk 'END{print NR}' file > new.file

but unfortunetly my file has 540 column seperated with ~ delimiter. While using this command for the file it shows error. "record .... too long"

if wc is working fine then you use line the below...

wc -l abc.dat|awk '{print $1}' >newfile

wc -l < abc.dat