Getting number of records from a table

I am doing a loading process. I am loading data from a Oracle source to Oracle target.

For example there is an SQL statement:

Insert into emp_1
Select * from emp_2 where deptno=20;

In this case my source is emp_2 and loading into my target table emp_1. This process is automated. Now I want a unix script which should generate a file after loading into the target is completed.

The file will have:

Number of records in emp_1 = <<>>
Number of records in emp_2 = <<>>

i.e. I want a script that would generate a file with the number of records in source and target table.

Thanks in advance.

SELECT COUNT(*) FROM emp_1;
SELECT COUNT(*) FROM emp_2;

if you have the file, the you can use wc or grep or awk command to count the no. of lines.

 
wc -l filename
grep -c . filename
awk 'END{print NR}' filename

Hi,

Thanks for the reply.

I want the count from Oracle table to a Unix file, not the count in a file.

For example a table has 300 records...I want script which counts the number of records from the table.

Thanks..