shell里for循环可以嵌套if吗

93次

问题描述:

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

为你推荐