开发者

linux shell script input line

quick question, how do I write a shell script that prompts users to enter let say 5 lines and it will stores those lines into a .t开发者_开发知识库xt file for example,

Today is hot 
Today is code 
Today is chilly
Today is windy
Today is sunny

not like

Today is hot  Today is code  Today is chilly Today is windy today is sunny

Thanks for your help


In bash you can do:

for i in {1..5}
do
  read line
  echo $line >> file.txt
done


Does this count?

sed 5q > file.txt
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜