shell for 循环

 

test.sh

#!/bin/bash
for str in "C语言" "http://www.bilibili.com" "成立7年了" "日IP数万"
do
    echo $str >>demo.txt  #将输入结果以追加的方式重定向到文件
done

 

执行

sudo chmod +x test.sh
./test.sh
cat demo.txt

输出

C语言
http://www.bilibili.com
成立7年了
日IP数万

 

posted @ 2019-04-23 23:58  anobscureretreat  阅读(156)  评论(0编辑  收藏  举报