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数万
原文地址:https://www.cnblogs.com/sea-stream/p/10759967.html