i do not know why this code stopped working i tested it a couple of times and it was running great what i am trying to do hear is place first and second in 2 different arrays and then comparing argument $2 ==> $comment to the array varA and if it is in the array i do not want to store it in the text file $file
comment=$2
dueD=$3
x=0
hasData()
{
declare -a varA varB
cat $file | while IFS=$'\t' read -r num first second;do
varA+=("$first")
varB+=("$second")
done
if [[ ${varA[@]} == ~$comment ]]; then
echo "already in the Todo list"
else
x=$(cat $file | wc -l)
x=$(($x+1))
echo -e "$x\t$comment\t$dueD" >> $file
fi
i think i am storing the values wrong in the array because when i try
echo ${varA[@]}
nothing gets printed more over i think my if statement is not accurate enough since this is the 4th time i edit it and it works but after a while it no longer works need assistance kindly
Aucun commentaire:
Enregistrer un commentaire