I have a directory name tmp on that directory on basis of FileName Category I wanted to create 'n' number of files dynamically.
if [ ! -d tmp ]
then
mkdir tmp
fi
TEMPDIR=$HOME/tmp
cd $TEMPDIR
array_FileName_category[0]="File1"
array_FileName_category[1]="File2"
array_FileName_category[2]="File3"
array_FileName_category[3]="File4"
a=0
while [ $a -le 9 ]
do
### Creating Source Files
${array_FileName_category[$a]}_file=$TEMPDIR/${array_FileName_category[$a]}_file_$$
a=`expr $a + 1`
done
but this is not working and giving the following errors:
File Not found with array prefix.
and the other error is for zero index of array ${array_FileName_Category[$a]} is not working
My Desired Output is: If there is FileCategory 'Sports' then at tmp directory using the while loop it will create a file with prefix Sports
cd -- "$TMPDIR"; mkdir -p -- "${array_FileName_category[@]}"kshdirectly for the files, I think - is thisksh93or ATTksh?teeortouchwould create the files, too, by the way.touchwould be much safer.