shell里for循环可以嵌套if吗

星星讲知识 | 学以知道 , 教以成德!         

问题描述

shell里for循环可以嵌套if吗,麻烦给回复
精选答案
最佳答案

我的回答:可以嵌套。

shell里面for循环是可以嵌套if条件语句的。举例:for i in `cat /etc/ansible/iplist`;doif echo $i |grep \"192\"; thenpass='Abc@123'echo \"$i ansible_ssh_port=22 ansible_ssh_user=root ansible_user_pass=\\\"$pass\\p\"\" >>/etc/ansible/hostselseecho $i >>/etc/ansible/hostsfidone

更多推荐
(c)2008-2025 广知网 All Rights Reserved 鄂ICP备2023002720号-19