0

I need to put $input into the file spelled.. but this code leaves the file empty. I am only correcting the first word that comes up in the array, so i'm thinking that when I just hit 'Enter' that it is rewriting the file over? any help?

# store words in file
cat $1 | ispell -l > file
# move words in file into array
array=($(< file))
# remove temp file
rm file
# print out words & ask for corrections
for ((i=0; i<${#array[@]}; i++ ))
do
        read -p "' ${array[i]} ' is mispelled. Press "Enter" to keep
this spelling, or type a correction here: " input
echo $input > spelled
done
# show corrections
cat spelled

1 Answer 1

1

Use >> instead of > if you want to append when the file exists.

echo $input >> spelled
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.