快速提问,如何编写一个shell脚本,提示用户输入5行,然后将这些行存储到.txt文件中,例如,
Today is hot
Today is code
Today is chilly
Today is windy
Today is sunny
不喜欢
Today is hot Today is code Today is chilly Today is windy today is sunny
感谢您的帮助
答案 0 :(得分:2)
在bash中你可以这样做:
for i in {1..5}
do
read line
echo $line >> file.txt
done
答案 1 :(得分:0)
这算了吗?
sed 5q > file.txt