Hi!
I’ve “looped” through Google but can’t find a solution to my problem.
I have some txt files where I need to add line number 2 inside the text file whenever a condition is true.
When some other conditions are met, I need to replace a substring in that line.
I have found a way to get the line numbers’ index, and a way to loop through the file.
But my loop only checks if the whole string is correct and not the index of the string.
My code is something like this:
for($i=0;$i-lt$len;$i++){ if($lines[$i] -in $indx1) { #do something } elseif ($lines[$i] -in $indx2) { #do something else } elseif ($lines[$i] -in $indx3) { #do something else } else { #do some other thing }
Since my $indx1 etc contains indexes and the $lines[$i] contains the whole string, the output is only the else-statement…
Anyone…?
Help is MUCH appreciated!