Working with FOR in ksh 88

Hi,
I tried the following but giving me all the files in the directory ,
Where i need the files which are assigned to variable like below

#!/bin/ksh

Src_Dir="/home/etc"
file_nm ="ab.temp"
  for File in `ls $Src_Dir/$file_nm*`
    do
    
    File=`basename $File`
    echo $File
  done

please help me

...
    for File in $Src_Dir/$File_nm*
...
1 Like

The suggestion hergp made shows you how to use the for loop. A simpler way to perform what this script does is:

#!/bin/ksh
Src_Dir="/home/etc"
file_nm ="ab.temp"
cd "$Src_Dir"
printf "%s\n" $file_nm*

If there is more to do in the script that needs to be run from the directory in which the script started, add the following line to the end of the script:

cd -

before the remainder of your code.

1 Like