if [ $VERSION == 1.1 ]
then
echo "version is 1.1"
for i in "subscriber promplan mapping dedicatedaccount faflistSub faflistAcc accumulator pam_account"
do
FILE="SDP_DUMP_$i.csv"
echo "$FILE"
if [ -e "$FILE" ]
then
echo "$FILE Exists"
else
echo "Creating $FILE"
touch $FILE
fi
i=`expr $i + 1`
done
else
echo "version is wrong"
fi
it has the common prefix "DUMP_" and suffix as ".csv"
so i used a for loop to check for matching the filenames
but i am getting error in touch command as
Creating
touch: missing file operand
Try `touch --help' for more information.
expr: syntax error
and also error in expr
and the extension .csv is not appending to the files
and its creating only DUMP_subscriber and other files without extension .csv
What is the expr for? If you want to loop around all those files you could use: for i in subscriber promplan mapping dedicatedaccount faflistSub faflistAcc accumulator pam_account
(without quotes)
$FILE = DUMP_subscriber.csv
then it will check in the directory if that file exist or not.
if not it will touch and create a file DUMP_subscriber.csv
in the code
FILE="SDP_DUMP_$i.csv"
for each counter it will create one file as in the 8
DUMP_accumulator.csv
DUMP_dedicatedaccount.csv
DUMP_faflistAcc.csv
DUMP_faflistSub.csv
DUMP_mapping.csv
DUMP_promplan.csv
DUMP_subscriber.csv
DUMP_pam_account.csv
and will check all the eight files
if its not exist it will create the file
for i in *.csv
do
#FILE="SDP_DUMP_$i.csv"
FILE="SDP_DUMP_$i" # otherwise you will end up with e.g. SDP_DUMP_DUMP_mapping.csv.csv
echo FILE: "$FILE"
if [ -e "$FILE" ]
then
echo "$FILE Exists"
else
echo "Creating $FILE"
touch $FILE
fi
#i=`expr $i + 1` # You cant add litteral with numeric... (expression error you had...)
# and There is not need to increment or change value, for does it automatically...
done