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数万
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数万