I am trying to loop through a set of files in a directory and do certain activities on them. When i execute the script with ksh it works as expected. But when i execute it with ./ it fails with error saying too many arguments. Please help with this.
ScriptName : Script1
When exec with ksh Script1 argument1
it is working as expected.
But when exec'd with ./Script1 argument1
is throwing too many arguments error.
#!/bin/bash
cd ../SrcFiles
if [ -e *$1* ]
then
for file in *$1*
do
echo $file
if [ $1 == "XXX" ]
then
echo $file >> ABC_"$1".txt
elif [ $1 == "YYY" ]
then
echo $file >> ABC_"$1".txt
else
echo $file >> ABC_"$1".txt
fi
done
else
#createadummyfile
fi