Please decode in English

Hello: Can anyone please decode this script in English. I have also made some comments which I know.. The actual script does not have one comment also..

#! /bin/ksh

. odbmsprd_env.ksh #setting the env..

echo $0 Started at : `date '+%d-%m-%Y %H:%M:%S'`
# what's echo $0

curdt=`date '+%Y%m%d%H%M%S'`

file=rpt
# why file=rpt

#what's $# ==3 -- I know we pass 3 parameters to the script and 3rd param is file name and 1st is startdate and 2nd is enddate.

if (( $# == 3 ))
then
echo arguments: $1 $2 $3
sql @rcvdata_p.sql $1 $2
file=$3
fi

# We are calling sql scripts to do some processing.
sql @rcvstmt3_p.sql
sql @rcvrep_p.sql

# We are checking number of lines in the file pur_jur.csv
lns=`cat pur_jur.csv|wc -l`

# If we have lines in the file, then do processing
if (( $lns > 0 ))
then
echo $lns records found in PURCHASE JOURNAL
# Debug into english the next line
sed 's/ //g' pur_jur.csv|sed 's/,//g'|sed 's/|/,/g' > pur_jur1.csv
# I understand the rest of the program
mv pur_jur1.csv pur_jur_"$file".csv
ftp_to_q_pnet.ksh pur_jur_"$file".csv
compress pur_jur_"$file".csv
mv /home/odbms/prod/cg_batch/purchase_journal/pur_jur_"$file".csv.Z /dataload/odbms/dataout/pur_jur_"$file".$curdt.csv.Z
else
echo No records found for Purchase Journal
rm pur_jur.csv
fi

echo $0 ended at : `date '+%d-%m-%Y %H:%M:%S'`

echo $0 will display the script's name

if (( $# == 3 ))

this asks "is the number of arguments = 3?"?

sed 's/ //g' pur_jur.csv|sed 's/,//g'|sed 's/|/,/g' > pur_jur1.csv

Take the file called pur_jur.ssv and make some changes:

  1. Remove all spaces
  2. Remove all commas
  3. Change any | to a comma
    Call the resulting file jur_jur1.csv

Thanks Perderabo for your response..

Just Two more Qns..

What is $0 ??
I know $1 is 1st parameter and so on..

Why is variable "file"=rpt ??

Please explain..

Thanks, ST2000

$0 is the name of the script. Suppose I type a command like this:

somescript option filename

You seem to know that $1 will be "option" and $2 will be "filename". You need to accept that $0 will be "somescript" as well.

As for:
file=rpt

This creates a variable named file and sets it equal to "rpt". You can see references to $file in a line like:
mv pur_jur1.csv pur_jur_"$file".csv

That will become
mv pur_jur1.csv pur_jur_rpt.csv

Great man.. Thx a lot again

ST2000