bash: incrementing variable outside scope of loop
Code:
[schneidz@hyper 2015-06-13]$ head test.* |
Your problem is that the use of the pipe causes the whole while loop to run in a separate process. Nothing in that child process can affect variables in the parent. This will work:
Code:
#!/bin/bash |
^ thanks, not quite solved. lets say instead of a file. the input of the loop is a string of commands:
Code:
#!/bin/bash |
You need to put variable s in the same shell as the while loop. Use parens to make subshell:
Code:
#!/bin/bash |
nah ... just use process substitution:
Code:
#!/bin/bash |
All times are GMT -5. The time now is 10:36 AM. |