Advertisement
v1ral_ITS

loop bash examples until condition met then finish

Aug 9th, 2018
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.47 KB | None | 0 0
  1. for I in 1 2 3 4 5
  2. do
  3.     statements1 #Executed for all values of ''I'',  up to a disaster-condition if any.
  4.     statements2 if (disaster-condition)
  5.     then
  6.     break #Abandon the loop.
  7.     fi
  8.     statements3 #While good and, no disaster-condition.
  9. done
  10.  
  11.  
  12. #!/bin/bash
  13. for file in /etc/*
  14. do
  15. if [ "${file}" == "/etc/resolv.conf" ]
  16. then
  17. countNameservers=$(grep -c nameserver /etc/resolv.conf)
  18. echo "Total ${countNameservers} nameservers defined in ${file}"
  19. break
  20. fi
  21. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement