append last line

Suppose i have a file FILE1.TXT

2293847982374 sdj 23423
2298372038974 dsj 23492
2972837629376 abj 34929
2984836398384 abc 39723

I want to append the above FILE1.TXT with total no of records and appending to the last line with "3000004" total 7 digits only, if 12 records then "3000012" to bottom of the line, in this case below

2293847982374 sdj 23423
2298372038974 dsj 23492
2972837629376 abj 34929
2984836398384 abc 39723
3000004

regards

awk 'END{print $0,"\n""3000004"}1' file

the no of records is not always the same. In the Input file there may be some more than 100 records we dont no...

BTW the above code has syntax error

>awk 'END{print $0,"\n""3000004"}1' file1.txt
awk: syntax error near line 1
awk: bailing out near line 1

I have bash and it's works fine,but perhaps you have another shell.

simple:
echo "3000004" >> FILE1.TXT

awk 'NF{c++;print} END{print (3000000 + c)}' inFile

i am getting syntax error as i want this in KSH script

>awk 'NF{c++;print} END{print (3000000 + c)}' ein_data_file.txt > ein_data_file1.dat
awk: syntax error near line 1
awk: bailing out near line 1
 

use either nawk or /usr/xpg4/bin/awk if on Solaris

$ cat FILE1.TXT
2293847982374 sdj 23423
2298372038974 dsj 23492
2972837629376 abj 34929
2984836398384 abc 39723

$ cat ./add_trailer.ksh
#!/bin/ksh
MYFILE=FILE1.TXT
FILECOUNT=$(wc -l < $MYFILE 2>/dev/null)
typeset -Z6 TRAILER=${FILECOUNT:-0}
echo "3$TRAILER" >> $MYFILE
exit 0

$ ./add_trailer.ksh

$ cat FILE1.TXT
2293847982374 sdj 23423
2298372038974 dsj 23492
2972837629376 abj 34929
2984836398384 abc 39723
3000004

thanks it works..

I also like to know i am getting some value into a variable using grep command

count_trlr=`grep "^3" $DATADIR/$FILE1.DAT| cut -c2-8`

After i get the value into variable i want to remove zeroes
eg: count_trlr=000004 but i want only the number 4 not zeroes like this, count_trlr=4

 
eg:
contr_trlr=0023343, i want 23343
contr_trlr=1111111, i want 1111111
contr_trlr=0222222, i want only 222222

how to do this in ksh script.

thanks in adv.

#!/bin/ksh

typeset -i count_trlr=$(grep "^3" $DATADIR/$FILE1.DAT| cut -c2-8)
$ contr_trlr=0023343
$ echo  $contr_trlr|tr -d '^0'
23343

$ contr_trlr=1111111
$ echo  $contr_trlr|tr -d '^0'
1111111

$ contr_trlr=0222222
$ echo  $contr_trlr|tr -d '^0'
222222