Breaking iteration after a given number of iterations (bash).
Hi:
Take this block of pseudocode: Code:
for i in $list; do |
Well you should think a bit more about the things you are trying to accomplish. You already have all the information you need.
1. $list is a list of stings as indicated by you 2. i must be a number if compared to one (generally) 3. break is the command to call to simply break the loop. IMHO it is never a good idea to exit an entire script from the middle of an operation like a loop. So using this information, restructure the script so items from step 1 and 2 are the correct types. |
Hi and thanks for your kind reply.
I think 5 must be the correct type. That is, instead of 5 I must write the 5th string in variable called list. Unfortunately this string consists of more almost 80 chars. There must be some other way for I do not thing there is a numeric type in bash. If the latter were true then a counter would solve the problem. Regards. |
than using > use string comparison operators like eq or ne
|
Quote:
Quote:
For example: Code:
#!/bin/bash Standard variables are typically string or numeric depending on what you assign to them: Code:
line="string" |
Your post greatly helps me, alghough I'm a bit confused about your statement:
Quote:
Code:
list=$(locate mimeTypes.rdf) I do not, please, want you to believe I want the full script running correctly by your intervention. But I think the best think I can do to give you the right picture is sending you it. Here it is. Code:
#!/bin/bash |
Quote:
To maybe help you further (I know I am not giving you direct answers here but am trying to help you learn as opposed to just telling you the answer), your pseudo code would look like: Code:
set a counter equal to 0 |
Thanks for your post again, grail.
About spaces interspersed in file names --what a fine occurrence to have provided for this! I say it ironically, I have something posted in my threads and a little thinking plus trial and error will give the answer. I think I have now all the elements to set to work. Which is what I'll do and, in case of any doubt, but remembering Quote:
|
Well I am glad I could help :) Please post your final solution so others can also learn from the process. (Also we might be able to provide further tips once you have a working solution)
Quote:
|
All times are GMT -5. The time now is 09:24 AM. |