I need to swap the position of two lines in a file accessing directly to them.
All the lines in my file have the same size in bytes, I know where every line is since they are all the same size, but I need to point to them directly without going through all the file.
So I need to know how to position myself there and how to read and delete them, and I really couldn't find a solution I understand.
Thanks in advance.
Example: I want to swap the second and fourth line.
File content:
1;first line ; 1
2;second line ; 1
3;third ; 2
4;fourth ; 2
5;fifth ; 2
How it should look:
1;first line ; 1
4;fourth ; 2
3;third ; 2
2;second line ; 1
5;fifth ; 2