bash shell while loop how to break out -


i want write bash shell script process text, might require while loop.

for example, while loop in c:

int done = 0; while(1) { ... if(done) break; } 

i want write bash shell script equivalent that. used , classic examples read have showed, this:

while read something; ... done 

it offers no how while(1){} , break;, defined , used in c, , not have read data stdin.

could me equivalency of above c code?

thanks.

it's not different in bash.

done=0 while : ;   ...   if [ "$done" -ne 0 ];       break   fi done 

: no-op command; exit status 0, loop runs until done given non-zero value.


there many ways set , test value of done in order exit loop; 1 show above should work in posix-compatible shell.


Comments

Popular posts from this blog

Unable to remove the www from url on https using .htaccess -