小编Has*_*ima的帖子

从文本文件一次只打印一行

如何一次仅打印或显示文本文件中的单词。当我运行我的脚本时,它应该只一个一个地显示文本文件中的每个单词,但只显示那个单词。

这是我所做的,但它将每个单词显示在单独的行上,但它显示了所有单词:

FS=$'\n'      
for j in `cat read`
do
    echo "$j"
done
Run Code Online (Sandbox Code Playgroud)

我希望输出看起来像这样:

root@matrix:~> first word  ---> this word disappear when second is displayed
root@matrix:~> second word ---> this disappear when third is displayed
root@matrix:~> third word  ---> this disappear when fourth is displayed and continues like this to the end of the file!
Run Code Online (Sandbox Code Playgroud)

command-line bash scripts text-processing

6
推荐指数
1
解决办法
9257
查看次数

标签 统计

bash ×1

command-line ×1

scripts ×1

text-processing ×1