Multiple runtime arguments

I am passing 3 runtime arguments to a shell script

$path crtl1 crtl2

the crtl files contains data(filename|date|count)

filename.txt|02/05/2010|10

The path contains the original data file,the code should fetch (filename|date|count) from original data file and it should match contents in crtl file.
but the path has 2 crtl files. the code should be in such a way it should match path and crtl1 file for first time,
and if doesnt match it should check for path and crtl2 file fr second time.
then it should as said above.

I have code for fetch details and comparing but for only path and one crtl file
I dont know how to loop for path and 2 crtl files. kindly help on this.

It would help a lot if you would send whatever code you have so far. Otherwise, it's just kind of guessing what you are trying to do, at least for me. :confused:

To the below i pass "path" and "crtlfilename" this code works for one crtl file what if the path contains 2 crtl files?? what changes needs to be done ??
first time it shud take path and crtl1 file and if doesnt match or filename not exist
it shud take path and crtl2 file and it shud check as per below code

echo "Initialising the run time parameter for FOLDER path..." 
cd  #path
echo "\n Folder path of the unzipped files and CNTRL file: $1 "
echo "\n \n Reading the content from CNTRL file and asssigning the values to variables..."
IFS='|'
while read -r fname Process_dt rec_cnt
do
 echo "\n $fname $Process_dt $rec_cnt "
 echo "\n Checking if the File exist in the folder..."
 if [ $fname ] 
        then
  echo "\n $fname Exist"
  echo "\n \n Reading linecount for the corresponding file and storing it in a variable..."
                cat $fname | wc -l | read linecount
  echo "\n Reading Processdate for the corresponding file and storing it in a variable..."
  ls -l | awk '{print $6 $7 S8}'| nawk ' { months="  JanFebMarAprMayJunJulAugSepOctNovDec";date=$2;month=index(months,substr($1,1,3))/3; year=$3; printf("%02s/%02s/%s\n",month,date,year)}'|read Proc_dt;
  echo "\n checking if record count and Process date of the file matches with the CNTRL file entry..."
                        if [ $linecount -eq $rec_cnt ] && [ $Proc_dt -eq $Process_dt ]   
                        then
     echo "\n \n Record Count and Process date matches from both files"
                       
                        elif [ $linecount -ne $rec_cnt ] 
                        then  
     echo "\n \n Record Count doesnot match"
   else
     echo "\n \n Process date doesnot match" 
   fi
 fi
 echo "Passing the run time parameter for CNTRL file name..."
done < POR.crtl #crtl file
echo " Filename,Record count and Process date validated against file $2"

One problem is change [ $filename ] to [ -f $filename ] (test for existence of regular file).

$ ls
jjj.c  jjj.txt  jjj.x

$ filename=jjj.c

$ [ -f $filename ]
$ echo $?
0

$ filename=junk

$ [ $filename ]
$ echo $?
0 # The problem. Says bad file exists.

$ [ -f $filename ]
$ echo $?
1 # Correct behavior now that -f is used.

---------- Post updated at 04:00 AM ---------- Previous update was at 03:49 AM ----------

Why do you use both awk and nawk? Seems confusing.

---------- Post updated at 04:01 AM ---------- Previous update was at 04:00 AM ----------

'{print $6 $7 S8}'

Is that supposed to be:

'{print $6 $7 $8}'

---------- Post updated at 04:03 AM ---------- Previous update was at 04:01 AM ----------

If the problem is with the long one-line awk script, it will be "awkward" to correct. You should try making that more readable, break it up into some smaller parts or whatever you can to make it easier to read and understand.

I think you took it in other way, I wont check for the presence of crtl files in the path that I am passing as an argument.
I match the contents of crtl files (filename|date|count) with that of fetched details(filename|date|count) of original data files.

No, you're mixed up (or the echo statements are totally misleading). Look again. Here is the wrong way:

echo "Checking if the File exist in the folder..."
if [ $fname ]; then
  echo "\n $fname Exist"

Here is the right way:

echo "Checking if the File exist in the folder..."
if [ -f $fname ]; then
  echo "\n $fname Exist"

while I pass 3 arguments

/path crtl1 crtl2

to a shell script will the console takes 2 crtl files in order ? Dont we need to specify to terminal that it should process 2 process or it takes automaticaly ?

I'm sorry. I'm trying to help. But I don't understand what you are trying to do. :confused: