Using "i" and "i+1" at the same time
Hi to all,
I have a list of files : file1, file2, ... file48, and I want to use each time 2 files. First file1 and file2, then file2 and file3, then file3 and file4 etc. In a for loop, is it possible to echo both "i" and "i+1" from my file list? Thanks in advance. |
Which language are you using?
|
Hi,
the logic you need is (this is in PHP): PHP Code:
|
How about this?
Code:
#!/bin/bash |
i=i+1, i++, and other variations thereof, when done in an arithmetic context, set the variable to the new value. Once executed, the previous value is lost.
To add another variation to the above suggestions, how about simply using a second variable? Code:
nofiles=20 Code:
files=( * ) |
Thank you all for your answers.
Currently I solved this in a more "newbie" way. Maybe I should have added that I read my list of files from a text file. Again, many thanks! |
All times are GMT -5. The time now is 05:08 AM. |