Разместил мой код ниже, задаваясь вопросом, могу ли я найти в одном массиве совпадение ... или есть ли способ найти файл unix внутри аргумента.
#!/bin/bash
# store words in file
cat $1 | ispell -l > file
# move words in file into array
array=($(< file))
# remove temp file
rm file
# move already checked words into array
checked=($(< .spelled))
# print out words & ask for corrections
for ((i=0; i<${#array[@]}; i++ ))
do
if [[ ! ${array[i]} = ${checked[@]} ]]; then
read -p "' ${array[i]} ' is mispelled. Press "Enter" to keep
this spelling, or type a correction here: " input
if [[ ! $input = "" ]]; then
correction[i]=$input
else
echo ${array[i]} >> .spelled
fi
fi
done
echo "MISPELLED: CORRECTIONS:"
for ((i=0; i<${#correction[@]}; i++ ))
do
echo ${array[i]} ${correction[i]}
done
в противном случае мне нужно было бы написать цикл for для проверки каждого индекса массива, а затем каким-то образом принять решение о том, пройти ли цикл и напечатать / принять ввод