OK, first of all, when I said that it works perfectly and it is just slow - this is not the case (too much beer
).
It is for a trivia-game, what I want to do is read a random line, remove the question number from the string, then write it into a new file with question number 1, then 2, 3 etc.
This way the questions get shuffled, and has different numbers. (because some people use the numbers, or the pattern that the questions appear, to cheat)
Now you know what I want to do and why. This is basically what I have so far:
I generate a random number, then $read -l <number>, remove the question number from the string (and use that number to $write -dl <number>), but then I realised if my next random string is lower down in the file, my question number is not going to respond to the line where it is, and I'm deleting the wrong line!
I thought of the $fread, but as far as I could see, there is no way to remove the line with $fwrite.
The reason speed is so important, I want my bot to shuffle when it gets to the end of the file (and then the game has to stop for such a long time).
I suppose I can copy the file and let the bot continue and only stop when the shuffling is complete, and start with the newly generated file. But now I'm back to square one with the removing of the line again. *sigh*
Thanks for the replies so far...