Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/file/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
File Unix Shell脚本-将$input放入文件_File_Shell_Pipe - Fatal编程技术网

File Unix Shell脚本-将$input放入文件

File Unix Shell脚本-将$input放入文件,file,shell,pipe,File,Shell,Pipe,我需要将$input放入拼写为。。但此代码将文件保留为空。我只是在更正数组中出现的第一个单词,所以我想当我点击“回车”时,它是在重写文件吗?有什么帮助吗 # 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 correction

我需要将$input放入拼写为。。但此代码将文件保留为空。我只是在更正数组中出现的第一个单词,所以我想当我点击“回车”时,它是在重写文件吗?有什么帮助吗

# 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
#将单词存储在文件中
cat$1 | ispell-l>文件
#将文件中的字移动到数组中
数组=($(<文件))
#删除临时文件
删除文件
#打印单词并要求更正
for((i=0;我拼写了
完成
#显示更正
猫拼写

如果要在文件存在时追加,请使用
>
而不是

echo $input >> spelled