parameter

I need to pass a filename parameter in shell script and then need to validate same name in the folder, Can any one help what would be piece of code to do so.

Lets folder is a and file with a is test.dat

and i want to pass this parameter against the file name file_name and then want to compare this name within the folder.If same then do otherwise return a error.

#!/usr/bin/ksh

fname="$1"

fldr="/tmp"

if [ -f "$fldr/$fname" ]
then
echo "File exists... congrats !!"
else
echo "File don't exists..!!"
fi

$1 is the first input parm
$2 is the second input parm
You can max input 9 parms $1-$9

You should run the script like this

./test_program file_name folder_name

then file_name will be assigned to $1
folder_name will be assigned to $2

I guess we can have more than 9 params using shift command....

It is long time since I used these I don't remember well.

mahendramahendr is right

for example
./test 1 2 3 4 5 6 7 8 9 10 11 12

#!/bin/sh

while [ -n "$1" ];do
   echo "$1 $2"
   shift 2
done

The output should be

1 2
3 4
5 6
7 8
9 10
11 12

Hope to help you

thanks
can also you tell me

echo "At the start of Data Files Check " >>  $REPFILE
#
if [ ! -f $P_INPUT_DIR/$P_FILENAME ]
then
    echo  $P_INPUT_DIR/$P_FILENAME " does not exist"
    echo "**************************************************" >> $REPFILE
    echo "*$P_SOURCE_DIR/$P_FILENAME " does not exist"           *" >> $REPFILE
    echo "**************************************************" >> $REPFILE
    echo "*THE FILE "$P_FILENAME " does not exist in the  *"$P_SOURCE_DIR >> $REPFILE
    PROBLEMS=1
    exit 1

after that I am executing a commaond

cd $P_INPUT_DIR
ls -rt | grep -v '^archive$' | sed '$d' | xargs -I{} mv {} archive/{}.orig

now i want to re start of Data Files Check in archive folder, the original file is just added with .orig then what would be additional line i need to write to do this also